Vba 文档。打开格式:.mht(word格式)

Vba 文档。打开格式:.mht(word格式),vba,ms-word,mhtml,Vba,Ms Word,Mhtml,问题:Word有时不会自动为.mht文件选择单文件网页格式 说明: 在Word应用程序中打开文件时,可以选择文件转换格式: 为了正确解码/查看.mht文件,我注意到选择单文件格式的网页效果非常好 有可能通过编程实现这一点吗?假设我想在word应用程序中打开.mht文件,并使用word的转换器将其视为单个文件网页文件 到目前为止,我发现Documents.Open方法接受参数格式。但它似乎没有我需要的格式。我看到的最接近wdOpenFormatWebPages7,但它与单文件网页不同 VB: C:

问题:Word有时不会自动为.mht文件选择单文件网页格式

说明: 在Word应用程序中打开文件时,可以选择文件转换格式:

为了正确解码/查看.mht文件,我注意到选择单文件格式的网页效果非常好

有可能通过编程实现这一点吗?假设我想在word应用程序中打开.mht文件,并使用word的转换器将其视为单个文件网页文件

到目前为止,我发现Documents.Open方法接受参数格式。但它似乎没有我需要的格式。我看到的最接近wdOpenFormatWebPages7,但它与单文件网页不同

VB:

C:

大家好, Microsoft支持部门已经记录了这个.mht问题,并提供了一个简单的解决方案。我使用它从PSR.exe中快速获取“Word格式的高度详细的QA和培训文档”,从Win7开始,所有Windows终端中都提供了该记录。我有一个转换脚本,可以为我公司的测试人员/培训师批量执行。使用正确的标题和命令“dir/b”,它还构建了一个目录,以帮助研究新员工:

Ref : https://support.microsoft.com/en-us/topic/the-confirmconversions-property-in-macro-changes-the-confirm-conversion-at-open-option-in-word-6f16c1db-4cb8-2727-dc4f-fdf6ef112ff5

Sub MyDocumentOpenMacro()

   Dim x As Integer

   ' Set x equal to the current setting of the Confirm conversion at Open
   ' option before opening your file.
   x = Application.Options.ConfirmConversions

   ' Open your file.
   Documents.Open "C:\My Documents\Address.txt", ConfirmConversions:=False

   ' Use a conditional statement to set the Confirm conversion at Open
   ' option back to its setting (value of x) before opening your file.
   If x = "0" Then
      Application.Options.ConfirmConversions = False
   Else
      Application.Options.ConfirmConversions = True
   End If

End Sub
大家好, Microsoft支持部门已经记录了这个.mht问题,并提供了一个简单的解决方案。我使用它从PSR.exe中快速获取“Word格式的高度详细的QA和培训文档”,从Win7开始,所有Windows终端中都提供了该记录。我有一个转换脚本,可以为我公司的测试人员/培训师批量执行。使用正确的标题和命令“dir/b”,它还构建了一个目录,以帮助研究新员工:

Ref : https://support.microsoft.com/en-us/topic/the-confirmconversions-property-in-macro-changes-the-confirm-conversion-at-open-option-in-word-6f16c1db-4cb8-2727-dc4f-fdf6ef112ff5

Sub MyDocumentOpenMacro()

   Dim x As Integer

   ' Set x equal to the current setting of the Confirm conversion at Open
   ' option before opening your file.
   x = Application.Options.ConfirmConversions

   ' Open your file.
   Documents.Open "C:\My Documents\Address.txt", ConfirmConversions:=False

   ' Use a conditional statement to set the Confirm conversion at Open
   ' option back to its setting (value of x) before opening your file.
   If x = "0" Then
      Application.Options.ConfirmConversions = False
   Else
      Application.Options.ConfirmConversions = True
   End If

End Sub

尝试在手动打开文件时录制宏,然后查看Word录制的内容。谢谢您的想法。但是,无论我在提示中选择什么,录制始终显示“wdOpenFormatAuto”格式。Documents.Open FileName:=test.mht,ConfirmConversions:=True,ReadOnly:=\uFalse,AddToRecentFiles:=False,PasswordDocument:=,PasswordTemplate:=,Revert:=False,WritePasswordDocument:=,WritePasswordTemplate:=,\uFormat:=wdOpenFormatAuto,XMLTransform:=回到真实的机器上。。。我也找不到类似的。顺便说一句,这是C代码,不是VBA。您可以查看FileConverter对象的文档-根据这一点,转换提示符中的列表来自这些,虽然这里的快速检查只会显示最后四个,但我认为其他的都是内置的,因此没有单独的转换器。如果关闭该选项,*.mht文件是否正确打开?Word是否自动选择单个网页选项以反映wdOpenFormatAuto?问题中的问题描述并不清楚……是的,问题是Word有时不会自动选择单文件网页。它为某些文件设置“纯文本”,但这些文件未正确打开。所以我有一个想法,强迫它选择单文件网页格式。啊,可以理解,那么。我唯一想到的另一种可能性是在转换对话框中使用SendKeys,但这并不理想!在您的位置上,我可能还会仔细查看mht文件中的前几行代码,看看这些单词是否可以识别,以及它们以纯文本形式打开时是否有区别。后者中可能缺少标记或属性,您可以在打开之前添加这些标记或属性…尝试在手动打开文件时录制宏,查看Word录制的内容。谢谢您的建议。但是,无论我在提示中选择什么,录制始终显示“wdOpenFormatAuto”格式。Documents.Open FileName:=test.mht,ConfirmConversions:=True,ReadOnly:=\uFalse,AddToRecentFiles:=False,PasswordDocument:=,PasswordTemplate:=,Revert:=False,WritePasswordDocument:=,WritePasswordTemplate:=,\uFormat:=wdOpenFormatAuto,XMLTransform:=回到真实的机器上。。。我也找不到类似的。顺便说一句,这是C代码,不是VBA。您可以查看FileConverter对象的文档-根据这一点,转换提示符中的列表来自这些,虽然这里的快速检查只会显示最后四个,但我认为其他的都是内置的,因此没有单独的转换器。如果关闭该选项,*.mht文件是否正确打开?Word是否自动选择单个网页选项以反映wdOpenFormatAuto?问题中的问题描述并不清楚……是的,问题是Word有时不会自动选择单文件网页。它为某些文件设置“纯文本”,但这些文件未正确打开。所以我有一个想法,强迫它选择单文件网页格式。啊,可以理解,那么。我唯一想到的另一种可能性是在转换对话框中使用SendKeys,但这并不理想!在你的位置上,我也可以仔细观察第一个f 查看mht文件中的代码行,以查看识别的单词与以纯文本形式打开的单词之间是否存在差异。后者中可能缺少一个标记或属性,您可以在打开之前添加该标记或属性。。。
Ref : https://support.microsoft.com/en-us/topic/the-confirmconversions-property-in-macro-changes-the-confirm-conversion-at-open-option-in-word-6f16c1db-4cb8-2727-dc4f-fdf6ef112ff5

Sub MyDocumentOpenMacro()

   Dim x As Integer

   ' Set x equal to the current setting of the Confirm conversion at Open
   ' option before opening your file.
   x = Application.Options.ConfirmConversions

   ' Open your file.
   Documents.Open "C:\My Documents\Address.txt", ConfirmConversions:=False

   ' Use a conditional statement to set the Confirm conversion at Open
   ' option back to its setting (value of x) before opening your file.
   If x = "0" Then
      Application.Options.ConfirmConversions = False
   Else
      Application.Options.ConfirmConversions = True
   End If

End Sub