>Hi everyone:
>
>back again for more advice on automating word 97 from foxpro 8.0. i ran my program in windows 2000 and it worked fine. now i run it in xp and i notice two differences.
>
>my program in foxpro 8.0 opens word application, creates a word document (naming it to differentiate it from other word documents opened through the same application - ie :
>
>oWord = Createobject("word.application")
>oWord.Visible = .T.
>oDocument_comprom = oWord.Documents.Add
>oRange = oDocument_comprom.Range()
>
>therefore, the document reference is "oDocument_comprom".
>
>I also reference a directory where the user opens a a specific file and call that directory "current_directory" ie:
>
>current_directory = justpath(lcfile)
>
>where lcfile is the name of the file opened with getfile()
>
>Now, to my problem. when i try to save the document, the following code works perfectly in Windows 2000:
>
>oDocument_comprom.SaveAs(current_directory + "\rom_comparison" + ".doc")
>
>When I try to save it in Windows XP home, 2 things happen:
>
>1. "current_directory" now stores the backslash at the end of the name, which is not how it is stored in Windows 2000 (ie xp = "c:\", 2000 = "c:")
>
>2. when i make the change to accommodate the above change noted in #1 above, i get an error "server threw an exception".
>
>i've tried fooling around with the saveas code and have actually made it work once under xp, but then word closed with an error message. when i tried again, i again received the "server threw an excpetion" error. other error messages with fooling around with the code have included "type mismatch".
>
>sorry for the long-winded message here. just want to give enough info. any suggestions to fix this would be greatly appreciated!
>
>TIA
>
>Paul
Paul,
To be sure on any system what I do is:
.SaveAs(addbs(current_directory) + "rom_comparison" + ".doc")
PS: Instead of declaring and holding extra references like oDocument_comprom, oRange I suggest you to use:
with oWord.Documents.Add
or:
oWord.ActiveDocument
etc. If you create ref. variables be sure to get rid of them ASAP.
Cetin