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

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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