Paste Command Failing (1 Viewer)

ill_comms

New member
Local time
Today, 18:00
Joined
Apr 17, 2008
Messages
9
Hi, I have a Word Macro that does the following:

1. Opens Word document with macro in it "DOC1".
2. Creates a new document "DOC2".
3. Opens another document "DOC3" that is acting like a template of sorts.
4. DOC2 is selected and copies the entire document to the clipboard. Then pastes it into DOC3.

Code:
    Documents(templateDocumentName).Select
    Selection.WholeStory
    Selection.Copy
    Documents(newDocumentName).Activate
    Selection.PasteAndFormat (wdPasteDefault)

This works perfectly in XP however falls over when run in Vista, both machines are using Office 2003.

The error is occuring on: "Selection.PasteAndFormat (wdPasteDefault)" and only producing a "Command Failed" error.

What could be causing this and does anyone have a fix?

Regards Hayden
 

Vassago

Former Staff Turned AWF Retiree
Local time
Today, 04:00
Joined
Dec 26, 2002
Messages
4,751
Are they both running the same or different versions of Access? I'm assuming it's a problem with references. In the Visual Basic editor, go to Tools and References and make sure they match on both machines (what is checked) if they don't check the ones that don't match.
 

ill_comms

New member
Local time
Today, 18:00
Joined
Apr 17, 2008
Messages
9
Re: Paste Command Failing [ANSWERED]

Hi Vassago,

I think I've solved this, it appears that that activating the document was not enough I had to do a select command as well.

Regards Hayden
 

Users who are viewing this thread

Top Bottom