>I have a VFP app that uses OLE automation to load RTF documents into Word and save them as HTML. This occurs many times a day. The code I use is:
>
>wd=createobject('word.application')
>wd.documents.open(m.infile)
>wd.ActiveDocument.SaveAs(m.tname,106)
>wd.quit
>release wd
>
>The problem is that the number (106) used in the SaveAs() method varies from machine to machine. On one machine, it's 106. On another, it's 102. On still another, I believe it is 111. (I used the macro recorder to determine the numbers.)
>
>Even more confusing is that with Word 2K, it uses a variable reference which I haven't any clue how to resolve.
>
>Is there any way to set this up where I can run this from any machine and not just the "matching" computer?
>
>I thought about using IE, but I'm having the same problem determining all of the WBExec() parameters to use to Save As HTML.
>
>Any help will be greatly appreciated!
Keith,
In wd2000 what you get is wdFormatHTML constant. You can download word constants header from MS site or files section. The one at files section probably doesn't have that constant because it was introduced with wd2000. Another way to get value is :
-Open tools\Macros\VBEeditor
-Press F2 to launch object browser
-From left pane locate wdSaveFormat
-Click wdFormatHTML on right pane
-Read the value that's beneath the panes
For those that do not have entries in constants header file are presented with numbers as you experienced and changes from computer to computer. Change your code to get that number for you :) (Code is not tested for syntax errors but I hope I code right)
wd=createobject('word.application')
with wd
.documents.open(m.infile)
with .Application
for each oConverter in .FileConverters
if oConverter.ClassName = "HTML"
wd.ActiveDocument.SaveAs(m.tname,oConverter.SaveFormat)
endif
endfor
endwith
.quit
endwith
Cetin