What saveas code should be used for .mht files

H

Hollis D. Paul

I am now saving word files in .mht format for use in SharePoint. When
I use the Word save-as dialog and choose Single File Web Page,
SharePoint Portal Server 2003 uploads and processes it with no
problems. The document appears in the document library and I can open
it from there. When I save word documents programmatically, I have the
choice of using wdFormatHTML = 8, and wdFormatFilteredHTML = 10.
However, neither of these formats can be uploaded as .mht files. So
the question is, what code can be used to produce a real .mht file
programmatically.

Hollis D. Paul [MVP - Outlook]
(e-mail address removed)

Using Virtual Access 4.52 build 277 (32-bit), Windows 2000 build 2600
http://search.support.microsoft.com/kb/c.asp?FR=0&SD=TECH&LN=EN-US

Mukilteo, WA USA
 
C

Cindy M -WordMVP-

Hi Hollis,

See if this property does what you need. And if it does, I'd appreciate a
confirmation :)

Application.DefaultWebOptions.SaveNewWebPagesAsWebArchives
I am now saving word files in .mht format for use in SharePoint. When
I use the Word save-as dialog and choose Single File Web Page,
SharePoint Portal Server 2003 uploads and processes it with no
problems. The document appears in the document library and I can open
it from there. When I save word documents programmatically, I have the
choice of using wdFormatHTML = 8, and wdFormatFilteredHTML = 10.
However, neither of these formats can be uploaded as .mht files. So
the question is, what code can be used to produce a real .mht file
programmatically.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
H

Hollis D. Paul

See if this property does what you need. And if it does, I'd appreciate a
confirmation :)

Application.DefaultWebOptions.SaveNewWebPagesAsWebArchives
Thanks, Cindy, for the suggestion.

I put that line just before the .saveas 8, and a dialog box popped up asking
me if I wanted to save the changes to the file, so I wound up saving it as a
one page web file. That isn't exactly what we hoped it would do.

Below is the code:

Function PrintDocs(o_item,strWordTemplate)

dim strSaveName
Dim MyDoc
Dim MyBIProps
Dim TitleProp
Dim SubjectProp
Dim strSubject
Dim strPos
Dim strFileName
Dim FirstChar

'MsgBox "We are in PrintDocs - VBScript"

strSaveName = "TestDoc" & i+1 & ".XML"

'Open a new letter based on the selected template
appWord.Documents.Add strWordTemplate
appWord.Visible = True
Set MyDoc = appWord.ActiveDocument

MyDoc.Content.InsertAfter o_item.Body

strSubject = o_item.Subject

strSubject = Replace(strSubject, """", "")
' MsgBox "1strSubject = " & strSubject

strSubject = Right(strSubject, Len(strSubject) - 5 )
' MsgBox "2strSubject = " & strSubject

' Set Title and Topic properties to strSubject
'Write information to Word custom document properties
'Set prps = appWord.ActiveDocument.CustomDocumentProperties

Set MyBIProps = MyDoc.BuiltInDocumentProperties

Set TitleProp = MyBIProps("Title")
TitleProp.Value = strSubject

Set SubjectProp = MyBIProps("Subject")
SubjectProp.Value = strSubject

strFileName = strSubject
strFileName = Replace(strFileName, ".", "")
strFileName = Replace(strFileName, ",", "")
strFileName = Replace(strFileName, "\", "")
strFileName = Replace(strFileName, " ", "_")
strFileName = Replace(strFileName, ":", "")
strFileName = Replace(strFileName, "(", "")
strFileName = Replace(strFileName, ")", "")

strFileName = Left(strFileName, 50)

' MsgBox "FileName = " & strFileName

strSaveName = "C:\3_SharePointXML\" & strFileName & ".mht"

'Application.DefaultWebOptions.SaveNewWebPagesAsWebArchives
appWord.DefaultWebOptions.SaveNewWebPagesAsWebArchives
MyDoc.SaveAs strSaveName, 8

MyDoc.close

Set MyBIProps = Nothing
Set TitleProp = Nothing
Set SubjectProp = Nothing
Set MyDoc = Nothing

o_item.Mileage = "XML File Created"
' o_item.Save

fLetterCreated = True

End Function


Hollis D. Paul [MVP - Outlook]
(e-mail address removed)

Using Virtual Access 4.52 build 277 (32-bit), Windows 2000 build 2600
http://search.support.microsoft.com/kb/c.asp?FR=0&SD=TECH&LN=EN-US

Mukilteo, WA USA
 
H

Hollis D. Paul

See if this property does what you need. And if it does, I'd appreciate a
confirmation :)
I don't know if you saw the note in the Automation NG, but here is the final
result.

I have changed things around in the script, and now the files are being
saved, using the value of 9, and the files were then successfully uploaded
to a SPPS doclib as .mht files. I suspect that the script was completing
too fast and destroying objects before they were finished as sources. Don't
know for sure, but that explanation is all I have to offer.

Hollis D. Paul [MVP - Outlook]
(e-mail address removed)
Mukilteo, WA USA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top