我有这段 VB.NET 代码要转换为 VBScript。它基本上启动 Microsoft Word,显示打开对话框并邮件合并选定的文档。任何帮助将不胜感激。
Dim oMissing As Object = System.Reflection.Missing.Value
Dim oEndOfDoc As Object = "\\endofdoc"
Dim oFalse As Object = False
'Start Word and create a new document.
Dim oWord As Word._Application
Dim oDoc As Word._Document
oWord = New Word.Application()
oWord.Visible = True
'show box
Dim dlg As Word.Dialog = oWord.Dialogs(Word.WdWordDialog.wdDialogFileOpen)
Dim dlgType As System.Type = GetType(Word.Dialog)
' Set the Name property of the dialog box.
dlgType.InvokeMember("Name", Reflection.BindingFlags.SetProperty Or Reflection.BindingFlags.Public Or Reflection.BindingFlags.Instance, Nothing, dlg, New Object() {"C:\Documents and Settings\My Documents\MailMerge\"}, System.Globalization.CultureInfo.InvariantCulture)
Dim timeOut As Object = 0
Dim a As Int16 = dlg.Show(timeOut)
'if a document has been opened.
If (a = -1) Then
oDoc = oWord.ActiveDocument
oDoc.Select()
oDoc.MailMerge.OpenDataSource("C:\\usr\\mergequery.txt", oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing)
oDoc.MailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument
oDoc.MailMerge.Execute(oFalse)
'Close the original form document.
oDoc.Saved = True
oDoc.Close(oFalse, oMissing, oMissing)
End If