I have this snippet of VB.NET code that I want to convert to VBScript. It basically starts Microsoft Word, displays the Open dialog and mail merges the selected document. Any help will be highly appreciated.
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