Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSWord VB Macro

Status
Not open for further replies.

VisualBasicHelp

Programmer
Sep 7, 2005
74
GB
Hi,

I am trying to insert a page before pasting using macro. So that when pasted, it is pasted in a new page. I could do this using the paste icon on the standard toolbar like this -

CommandBars("standard").Controls("Paste").OnAction = "countPaste"

But if I try to do the paste by ctrl+v , I am not getting the required, can anybody please help me in this.

Thanks
 
Code:
Selection.InsertBreak Type:=wdPageBreak
will make a page break at the Selection point. Depening on where your paste is coming from:
Code:
With Selection
   .InsertBreak Type:=wdPageBreak
   .Paste
End With
will make a page break, then paste.

Gerry
 
But if I use this code means, what will happen is, whatever is in the clipboard will be pasted.

Actually I wanted to know if the user has opted for paste, that's why I have used "onaction". If so a function will be called which will check whether he is in the first page, if so it will paste or else, it will insert a page break and paste.

is there any other way out.


 
Why not attach the Ctrl+V keyboard to the countPaste macro ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks a lot, it worked with such a simple solution.

I was strugling with it from past 2 days. Thanks again.
 
one more question, using macro in word, can I do a ALT+Printscreen in another application and it should be automatically pasted in active word document.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top