Click here to Skip to main content
14,838,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I just created a office automation application that does the following...

  1. Opens a word document
  2. Does some text replacement
  3. Saves the document as a filtered html.

Now my issue is, when it's saving the document as html, it's converting all the objects into jpeg format. I want to be able to do the following,

  1. Save all the objects into phg or gif instead jpg
  2. Customize the pixels per inch settings
  3. Set the character encoding to UTF-8

I don't know how to access those settings. I need your help. Thank you.

Here Is My Code For The Conversion
Dim word_ As New Application 'create a word application
Dim open_file As New OpenFileDialog 'create a openfile dialog
Dim word_doc As Document 'create a word document
word_doc = word_.Documents.Open(open_file.FileName, False)

Dim save_file As New SaveFileDialog 'define a save dialog
save_file.Filter = "html files (*.html)|*.html" 'give its extension

If save_file.ShowDialog() = DialogResult.OK Then 'if ok click
  'save as html
  word_doc.SaveAs(save_file.FileName, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML)

End If

1 solution

Can you do this from within Word using any settings? If no, than you won't be able to do it using automation either. If yes, do a macro recording, and see, how the built-in automation is performing it. Since that's also VB, it will be easy to transcribe it to VB.NET.

WebOptions.AllowPNG[^] will allow you to save as PNG, but as I know, you can't infliuence downsamoling (see:[^]).

You could make tough a two-pass export: use non-filtered export to get the high-resolution images, and the filtered one to get the rest.
KrishanuDey 22-Dec-12 16:42pm
Yes I can set the pixel per inch setting in word 2010 from file->options->advanced->under the section "image size and quality",
Zoltán Zörgő 22-Dec-12 16:45pm
Yes, but is it used, when saving as filtered html? Are you sure? If yes, do a macro recording that includes both setting this value, and saving.
KrishanuDey 22-Dec-12 17:02pm
Ahh.. Just tested if is used when saving as a filtered html and found that it is not used while saving as a filtered html. Is there any other way to do the same?
Zoltán Zörgő 22-Dec-12 17:33pm
I am afraid not. You have two choices:
1) Save twice: without and with filtering, and use the images from the unfiltered one, and overwrite the filtered images
2) Save unfiltered, and do the filtering yourself. Well, that is lot of regular expression replaces.
+1) Try exporting from other word processing application, like LibeOffice
+2) Look for some app or library that can save a word document as html. You might find free ones, but commercials for sure...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900