Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetObject and MS Word

Status
Not open for further replies.

GeekGirlau

Programmer
Jul 29, 2001
216
AU
AAAAAAAAAAGGGGGGGGGGGGGGGGGGGGGHHHHHHHHHHH!

Sorry, had to get that out of my system.

I'm having trouble with using GetObject to manipulate Word from Access.

Sample:

Function StupidWord()
Dim objWord as Word.Application


On Error Goto ErrHandle

Set objWord = GetObject(, "Word.Application")

With objWord
.Visible = True
.Activate
End With


ExitRamp:
On Error Resume Next
Set objWord = Nothing
Exit Function


ErrHandle:
Select Case Err.Number
Case 91, 429
Err.Clear
Set objWord = CreateObject("Word.Application")
Resume Next

Case Else
MsgBox Err.Number & ": " & Err.Description
Resume ExitRamp
End Select
End Function

Problem is, it doesn't work (although the identical code using Excel works fine). I get error 429 as soon as I try to do CreateObject.

Currently I'm having to use Shell to launch Word instead of CreateObject, and replacing Resume Next with Resume. This occassionally decides to open Word twice before successfully using the GetObject command. I've tried dimensioning objWord as an Object rather than Word.Application, with no success.

I should also explain that I'm working with a large organisation with a standard installation procedure for Office, so I have zero flexibility for changing the way that Word and/or Access have been installed.

HELP!!!!!!!!
 
In Access 97 shouldn't the declaration be:

Dim WordObj As Object
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top