[edit to change ActiveDocument to ActiveWindow–that’s what I get for not cutting/pasting]
As a follow up question to my last post:
I have a document. Depending on a variable n, I need to copy the entire contents of the document, go to the end of the document, insert a page break, and paste the contents of the clipboard. Basically, I’m filling in some default information on a template, copying the default info, and then pasting it n times (in the same document). The code that launches this process is vbscript in an Outlook form.
This is where I am so far:
‘I’ve launched Word, created the new doc based on the template (as objDoc), and filled in the default info
‘copy the whole document at this point
objDoc.Select
objDoc.ActiveWindow.Selection.Copy
n = 1 ‘starting on the first evaluation
Do until rItem is nothing
‘check which item we’re on
If n=1 then
‘do nothing, there is only one item
Else
objDoc.ActiveWindow.Selection.WholeStory
objDoc.ActiveWindow.Selection.EndKey unit:=wdStory ‘***
objDoc.ActiveWindow.Selection.InsertBreak Type:=wdPageBreak
objDoc.ActiveWindow.Selection.Paste
End If
‘do my other stuff here
n=n+1
Loop
I get a “expected statement” error at the line ending with ‘***
This does not seem like it should be complicated, but I am at a complete loss. I am hoping it is just something stupid that I’m missing. Any thoughts would be appreciated…thanks in advance.
jen