Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Saving document as HTML
Message
From
11/04/2000 04:33:12
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
10/04/2000 23:12:17
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00357813
Message ID:
00357857
Views:
18
>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  && Using with..endwith is a good habit :)
  .documents.open(m.infile)
  with .Application && Not really needed at this level 
                    && but prevents errors if used at a lover level
      for each oConverter in .FileConverters
          if oConverter.ClassName = "HTML"
             wd.ActiveDocument.SaveAs(m.tname,oConverter.SaveFormat)
          endif
      endfor 
  endwith
  .quit
endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform