VB copying and pasting

BugBear

Board Regular
Joined
Oct 30, 2008
Messages
60
Hi All. This is VB embedded in Word but I am hoping you clever people can help me as you have done so many times before with my XL queries.

My code pastes a number of sheets to a new doc and saves before emailing. The only prob I have is that it adds a blank page which is fine if emailing but wasteful when printing. The code clearly states pages 7-9. Is there anyway I can stop VB adding a blank page on the end?

Any suggestions would be most appreciated. Thanks

If optage.Value = True Then
'to paste pages to new doc
Selection.GoTo what:=wdGoToPage, Which:=wdGoToAbsolute, Count:=7
Set rgePages = Selection.Range
Selection.GoTo what:=wdGoToPage, Which:=wdGoToAbsolute, Count:=9
rgePages.End = Selection.Bookmarks("\Page").Range.End
rgePages.Select
Selection.Copy
Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=0
Selection.PasteAndFormat (wdPasteDefault)

'and save as temp file
ActiveDocument.SaveAs FileName:=Environ("TEMP") & "\discrimtemp.doc"
ActiveDocument.Close
End If
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Not familiar with Word VB, but is it possible you are inserting your copied pages before the default page that is created with the new file?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top