problems with GetObject

T

Tom Jones

Dear all,

I have a problem with a vba script on just one PC. I am using the
following code to import the contents of another Word document into our
Letterhead templates when a new document is created:

'** Code begins
Sub Update_Partners()
Dim I, newfooter, footerBmark, update_loc
Set I = ActiveDocument
Dim oWordDoc As Word.Document
update_loc = "\\server1\data\footer.Doc"
'Open the document with GetObject (so it's invisible)
Set oWordDoc = GetObject(update_loc)
newfooter = oWordDoc.Bookmarks("steeles_footer").Range.Text
Set footerBmark = i.Bookmarks("steeles_partners").Range
footerBmark.Text = newfooter
footerBmark.Font.Bold = False
i.Bookmarks.Add Name:="steeles_partners", Range:=footerBmark
'Close the document
oWordDoc.Close
Set oWordDoc = Nothing
End Sub
'** Code ends

This works fine on all our PCs (over 150) - except for one, which hangs
for about 30 seconds on the GetObject statement. I have tried setting
the class (I think to "Word.Document" but that made no difference at
all.

Has anyone got any ideas what the problem could be (no luck on Google),
or if there is an alternative way of achieving the import of the file.

Thanks for any help you can provide,

Tom.
 
D

Doug Robbins - Word MVP

Hi Tom,

I think that you should be using

Set oWordDoc = Documents.Open (update_loc)

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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