stickleprojects Level: Moderator

 Registered: 09-09-2002 Posts: 1034
|
Re: Creating and editing a Word document
Hi
THe first problem indicates that your pointer to the WordApplication is destroyed - this happens when you use "set wordapplication = GetObject" or "set wordapplicatino = CreateObject " then someone closes word, then you attempt to resuse the wordapplciation without rerunning the getobject or createobject code.
You cannot modify an activedocument if there is no document open (you will get a similar problem to the above)
Pagesettings only work if you have a printer installed (and you have an activedocument open in word).
I suggest that you run your application to open word, then BEFORE YOU CLOSE WORD open the taskmanager, look in the processes tab for WinWord.exe, then close word (leave taskamanger open), now, how many winword.exe's do you have running?
I suspect it's either zero (your error 462 will occur if its zero) or one (your activedocument will fail)
Don't let the user close word whilst you have a WordApplication pointer that you expect to be connected to word. Let the user see the document after you have finished.
ie.
set objword = new word.application
set objdoc = objword.documents.open "c:fred.doc"
objdoc.inserttext "mooooo"
objdoc.save
objdoc.close
set objdoc = nothing
objword.quit
set objword= nothing
if msgbox("Want to see the document?",vbQuestion or vbYesNo) = vbyes then
shellexecute "c:fred.doc",1
end if
|
Hope this helps
Kieron
____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)
|