Problem with VBA and Access 2010

Good catch with the comma in GetObject.
Thanks!

I would still include the CreateObject line either with On Error Resume Next (like you had in your first post) or On Error Go To someline and CreateObject there (preferrable).
You're right, this morning the function didn't work again, probably because Word wasn't running. After making the following changes I got it to work:

Code:
On Error Resume Next
Set objWord = GetObject(, "Word.Application")
    If Err.Number <> 0 Then 'Word isn't already running
        Set objWord = CreateObject("Word.Application")
        blnCreated = True
    End If
On Error GoTo 0
 
As you can see and from your comments, that ensures that whatever the situation a Word instance is up and running before executing code below.

By the way, I would change On Error GoTo 0 to your previous old code line On Error GoTo ErrHandling.

Good luck with the rest of your project!
 

Users who are viewing this thread

Back
Top Bottom