将对象保存为png而不是jpg,同时使用办公自动化将word文档保存为vb.net中的过滤html [英] save objects as png instead jpg while saving a word document as filtered html in vb.net using office automation

查看:108
本文介绍了将对象保存为png而不是jpg,同时使用办公自动化将word文档保存为vb.net中的过滤html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚创建了一个办公自动化应用程序,它执行以下操作...

I just created a office automation application that does the following...



  1. 打开word文档
  2. 是否有一些文本替换
  3. 将文档保存为过滤的html。



现在我的问题是,当它将文档保存为html时,它正在将所有对象转换为jpeg格式。我希望能够做到以下几点,


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. 将所有对象保存为phg或gif而不是jpg
  2. 自定义每英寸像素数设置
  3. 将字符编码设置为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

推荐答案

您可以使用任何设置在Word中执行此操作吗?如果不是,那么你也无法使用自动化。如果是,请进行宏录制,并查看内置自动化如何执行。由于这也是VB,因此很容易将其转录为VB.NET。



WebOptions.AllowPNG [ ^ ]允许您保存为PNG,但据我所知,您不能影响缩减(请参阅: http://answers.microsoft.com/en- us / office / forum / office_2010-word / image-quality-changes-when-saving-as-web-page / 4c860944-c627-4fed-afd4-a7473ab1dee6 [ ^ ])。



您可以进行双向导出:使用非过滤导出来获得高分辨率图像和过滤后的一个得到剩下的。
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.


这篇关于将对象保存为png而不是jpg,同时使用办公自动化将word文档保存为vb.net中的过滤html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆