R – Why doesn’t SaveAs use correct PixelsPerInch in macro

ms-wordvba

I have a macro which converts Word docs to htm. The problem is that the images are always saved as 96 ppi, even though I have specified 240 ppi.

Any ideas on how to fix?

Here is my macro:

Sub Doc2htm()
     With ActiveDocument.WebOptions
        .RelyOnCSS = True
        .OptimizeForBrowser = False
        .OrganizeInFolder = True
        .UseLongFileNames = True
        .RelyOnVML = False
        .AllowPNG = True
        .ScreenSize = msoScreenSize800x600
        .PixelsPerInch = 240
        .Encoding = msoEncodingWestern
    End With
    With Application.DefaultWebOptions
        .UpdateLinksOnSave = True
        .CheckIfOfficeIsHTMLEditor = False
        .CheckIfWordIsDefaultHTMLEditor = False
        .AlwaysSaveInDefaultEncoding = False
        .SaveNewWebPagesAsWebArchives = True
    End With

    Dim newName As String
    Dim fileDir As String
    newName = ActiveDocument.Name
    If InStr(newName, ".doc") = 0 Then Exit Sub
    newName = Left(newName, InStr(newName, ".doc") - 1) & ".htm"
    fileDir = Left(ActiveDocument.FullName, InStrRev(ActiveDocument.FullName, "\"))

    ChangeFileOpenDirectory fileDir
    ActiveDocument.SaveAs FileName:=fileDir & newName, FileFormat:= _
        wdFormatFilteredHTML, LockComments:=False, Password:="", AddToRecentFiles _
        :=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _
        :=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
        SaveAsAOCELetter:=False
    'Application.Quit

End Sub

Best Answer

Try FileFormat:=wdFormatHTML rather than of FileFormat:= wdFormatFilteredHTML

From http://answers.microsoft.com/en-us/office/forum/office_2010-word/image-quality-changes-when-saving-as-web-page/4c860944-c627-4fed-afd4-a7473ab1dee6 "Saving as “Filtered’ HTML will remove any Office specific tags and make changes to the file to help insure browser compatibility. Beyond stripping tags, saving as Filtered HTML also will reduce images to screen resolution."

From Image quality in "Web Page, Filtered" "... this is by-default for Filtered webpage saves in Word. All mso tags are removed and it's made as small as possible by lowering the DPI to 96"

Related Topic