Good morning, all.
I have written a VBScript to save an uploaded document as HTML for our Intranet. The code works fine; the file is found, saved with the .htm extension, and then displayed. The only problem is that all formatting is lost, such as font sizes and bolding!
I have looked in the object browser in Word to see what the value is for SaveAs HTML and I have recorded a macro to get the value. When I record a macro, I am given the constant 100, but all the posts I read say that the value is 8. Well I have tried both of these and all I get when the file is saved is the text, all the same size, with no formatting. This makes me think that I am not really getting an HTML format, just a document saved with the .htm extension, if you know what I mean.
Here is a snippet of the code using the value 8 for wdSaveAsHTML:
****BEGIN SNIPPET*****
'create an instance of Word'
Set objApp = CreateObject("Word.Application"
'open the document'
set objDoc = objApp.Documents.Open("c:\temp\" & dname)
if err<>0 then
MsgBox "Can't open file!"
objDoc.close
objApp.quit
exit sub
end if
err.clear
objApp.ActiveDocument.saveas "c:\temp\" & newFileName, 8
if err<>0 then
MsgBox "Can't save file to temp directory!"
objDoc.close
objApp.quit
exit sub
end if
err.clear
******END SNIPPET*******
One odd thing: When I go into the Object Browser for Word, and search for wdSaveFormat, HTML is not listed as one of the formats. However, I CAN save a document, with the proper formatting, manually using File -> SaveAs HTML from the menu??!!??
I am running Office 97 on a WinNT 4 server.
Has anyone else had this problem? Any ideas, war stories, references or resources would be appreciated. Kathryn
I have written a VBScript to save an uploaded document as HTML for our Intranet. The code works fine; the file is found, saved with the .htm extension, and then displayed. The only problem is that all formatting is lost, such as font sizes and bolding!
I have looked in the object browser in Word to see what the value is for SaveAs HTML and I have recorded a macro to get the value. When I record a macro, I am given the constant 100, but all the posts I read say that the value is 8. Well I have tried both of these and all I get when the file is saved is the text, all the same size, with no formatting. This makes me think that I am not really getting an HTML format, just a document saved with the .htm extension, if you know what I mean.
Here is a snippet of the code using the value 8 for wdSaveAsHTML:
****BEGIN SNIPPET*****
'create an instance of Word'
Set objApp = CreateObject("Word.Application"
'open the document'
set objDoc = objApp.Documents.Open("c:\temp\" & dname)
if err<>0 then
MsgBox "Can't open file!"
objDoc.close
objApp.quit
exit sub
end if
err.clear
objApp.ActiveDocument.saveas "c:\temp\" & newFileName, 8
if err<>0 then
MsgBox "Can't save file to temp directory!"
objDoc.close
objApp.quit
exit sub
end if
err.clear
******END SNIPPET*******
One odd thing: When I go into the Object Browser for Word, and search for wdSaveFormat, HTML is not listed as one of the formats. However, I CAN save a document, with the proper formatting, manually using File -> SaveAs HTML from the menu??!!??
I am running Office 97 on a WinNT 4 server.
Has anyone else had this problem? Any ideas, war stories, references or resources would be appreciated. Kathryn