thebernieb
October 8th, 2001, 01:13 PM
Folks,
I've written a fairly simple utility to search a given directory for .DOC files and fill up a list box with the path\filename. After this is done it opens a new word.application object. Then it iterates through the list box, attempts to open each file, deletes the VB Code, attaches a new templates, saves, and then closes the document. Onces all of the documents have been "fixed" then word.application is 'quit'. I've tested it on my machine and it works great, but when I try to run it on the computer it was made for I get errors. It says object variable not set and returns line 8250:
8240 Set objDocument = objWordApp.Documents.Open(strDocFile)
8250 intCodeLineCount = objDocument.VBProject.VBComponents("ThisDocument").CodeModule.CountOfLines
8260 If intCodeLineCount > 0 Then objDocument.VBProject.VBComponents("ThisDocument").CodeModule.DeleteLines 1, intCodeLineCount
**objDocument uses late binding **objWordApp uses early binding
I just don't get it, I didn't jump into any With Blocks and I'm fairly certain the methods I used for the automation are tight. I'm sure it might be hard to help without seeing all of the code, but I didn't want to post too much and bore someone. Is it possible that on a slower machine it takes longer for the document to open and register thereby generating errors because the object is not fully loaded? I'm at a loss and tired of messing with this thing. Please HELP!!!
Thanks,
Bernie
I've written a fairly simple utility to search a given directory for .DOC files and fill up a list box with the path\filename. After this is done it opens a new word.application object. Then it iterates through the list box, attempts to open each file, deletes the VB Code, attaches a new templates, saves, and then closes the document. Onces all of the documents have been "fixed" then word.application is 'quit'. I've tested it on my machine and it works great, but when I try to run it on the computer it was made for I get errors. It says object variable not set and returns line 8250:
8240 Set objDocument = objWordApp.Documents.Open(strDocFile)
8250 intCodeLineCount = objDocument.VBProject.VBComponents("ThisDocument").CodeModule.CountOfLines
8260 If intCodeLineCount > 0 Then objDocument.VBProject.VBComponents("ThisDocument").CodeModule.DeleteLines 1, intCodeLineCount
**objDocument uses late binding **objWordApp uses early binding
I just don't get it, I didn't jump into any With Blocks and I'm fairly certain the methods I used for the automation are tight. I'm sure it might be hard to help without seeing all of the code, but I didn't want to post too much and bore someone. Is it possible that on a slower machine it takes longer for the document to open and register thereby generating errors because the object is not fully loaded? I'm at a loss and tired of messing with this thing. Please HELP!!!
Thanks,
Bernie