如何使用VBA宏问题中的翻译

时间:2019-05-21 15:25:15

标签: vba ms-word

想要“批量”翻译许多word文档。

试图批量转换为docx,需要添加翻译。

请在下面查看我正在使用的代码。

我不知道如何在ActiveDocument上调用翻译。

'''VBA
    Sub ConvertDocToDocx()
    'Updated by ExtendOffice 20181128
        Dim xDlg As FileDialog
        Dim xFolder As Variant
        Dim xFileName As String
        Application.ScreenUpdating = False
        Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
        If xDlg.Show <> -1 Then Exit Sub
        xFolder = xDlg.SelectedItems(1) + "\"
        xFileName = Dir(xFolder & "*.doc", vbNormal)
        While xFileName <> ""
            Documents.Open FileName:=xFolder & xFileName, _
                ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
                PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
                WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
                wdOpenFormatAuto, XMLTransform:=""

    'pseudo code ActiveDocument.MStranslateFromTo('EN','DA') 

            ActiveDocument.SaveAs xFolder & Replace(xFileName, "doc", "docx"), wdFormatDocumentDefault
            ActiveDocument.Close
            xFileName = Dir()
        Wend
        Application.ScreenUpdating = True
    End Sub
'''

(在此处找到代码:https://www.extendoffice.com/documents/word/5601-word-batch-convert-doc-to-docx.html#a1

1 个答案:

答案 0 :(得分:0)

没有答案

可以这样做,但是记录宏不会产生所需的结果。运行此代码时,唯一生成的代码是我选择代码的部分,我按翻译的部分等未记录-看起来像这样:

Sub Makro1()
'
' Makro1 Makro
'
'
    Selection.WholeStory
End Sub
```