Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    185
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Copy/paste within single doc (vbscript/Word/2ksr1)

    [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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Copy/paste within single doc (vbscript/Word/2ksr1)

    If you're using late binding, you can't use constants like wdStory and wdPageBreak. Try their numeric values 6 and 7, respectively.

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    185
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy/paste within single doc (vbscript/Word/2ksr1)

    Oh good grief.

    That did it. The stupid thing is, I *knew* that--I've been looking up numerical values for constants for other parts of the code for a few days now.

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •