Calling Word XP from Access 2k

D

Dedge

Hi. Can anyone help me with the following?

The code below works OK in Access 2000. But when it was
installed on a PC with office XP, it failed at the "Set
appword . . . " line with "runtime error 429: ActiveX
component can't create object".

Is there a way of coding this to work on both 2k and XP?
Does something need to be changed on the xp PC? I'm using
2k myself, and don't have easy access to xp for testing.

Would be very grateful for any suggestions. Thanks

** START OF CODE EXTRACT
Dim appWord As Word.Application
' Switch to Microsoft Word so it won't go away when
you finish.
On Error Resume Next
AppActivate "Microsoft Word"
' If Word isn't running, start and activate it.
If Err Then
Shell "c:\Program Files\Microsoft Office\Office\"
& "Winword /Automation", vbMaximizedFocus
AppActivate "Microsoft Word"
End If
On Error GoTo 0
' Get an appication object so you can automate Word
Set appWord = GetObject(, "Word.Application")
' Open a document based on the memo template, etc.
With appWord
.Documents.Add wordtemplate_path
[. . Do various things with the document . . ]
End With

** END OF CODE EXTRACT
 
P

Peter R. Fletcher

I have Access applications running Word Automation using both
versions of Office without code changes. Check that you don't have a
Reference problem on the system where the Set is failing.

Hi. Can anyone help me with the following?

The code below works OK in Access 2000. But when it was
installed on a PC with office XP, it failed at the "Set
appword . . . " line with "runtime error 429: ActiveX
component can't create object".

Is there a way of coding this to work on both 2k and XP?
Does something need to be changed on the xp PC? I'm using
2k myself, and don't have easy access to xp for testing.

Would be very grateful for any suggestions. Thanks

** START OF CODE EXTRACT
Dim appWord As Word.Application
' Switch to Microsoft Word so it won't go away when
you finish.
On Error Resume Next
AppActivate "Microsoft Word"
' If Word isn't running, start and activate it.
If Err Then
Shell "c:\Program Files\Microsoft Office\Office\"
& "Winword /Automation", vbMaximizedFocus
AppActivate "Microsoft Word"
End If
On Error GoTo 0
' Get an appication object so you can automate Word
Set appWord = GetObject(, "Word.Application")
' Open a document based on the memo template, etc.
With appWord
.Documents.Add wordtemplate_path
[. . Do various things with the document . . ]
End With

** END OF CODE EXTRACT


Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
D

Dedge

Thanks, Peter.

That would be a reference to the relevant Word Object
Library, yes? I'll certainly check that--as soon as the
owner of the PC concerned comes back from vacation!!

Dedge
 
P

Peter R. Fletcher

Most likely, but be aware that any missing Reference can cause
problems, particularly, if it is not the bottom one in the list -
subsequent ones will not be found, even if they are present.

Thanks, Peter.

That would be a reference to the relevant Word Object
Library, yes? I'll certainly check that--as soon as the
owner of the PC concerned comes back from vacation!!

Dedge


Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top