Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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)
 
  'close
  word_doc.Close(False)
End If
Posted 22-Dec-12 10:59am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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: http://answers.microsoft.com/en-us/office/forum/office_2010-word/image-quality-changes-when-saving-as-web-page/4c860944-c627-4fed-afd4-a7473ab1dee6[^]).
 
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.
  Permalink  
Comments
Member 7778536 at 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ő at 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.
Member 7778536 at 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ő at 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)



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100