Jump to content

Com and MS-Word Mail merge


Recommended Posts

Hi,

I am attempting to perform a mail merge using a word doc and tab delimited csv file and am failing badly.

I need some-one to convert a vb script to autoit for me.

Activedocument.MailMerge.OpenDataSource  _ 
      Name:="X:\WindowsIsWierd\Temp\merge.txt", _
      ConfirmConversions:=False,_
      ReadOnly:=False, LinkToSource:=True, _
      AddToRecentFiles:=False,_
      PasswordDocument:="",  _
      PasswordTemplate:="", _
      WritePasswordDocument:="", _
      WritePasswordTemplate:="",  _
      Revert:=False, _
      Format:=wdOpenFormatAuto, _
      Connection:="", _
      SQLStatement:="", _
      SQLStatement1 _ :="")

To an autoIT version

Here is my attempt

$word = ObjCreate("word.application"); to run word
$word.visible = 1; to show it
$word.documents.open(@ScriptDir & "\NewRateQuote.doc"); to make a new document
$mm = $word.MailMerge.OpenDataSource("Name:=" &@ScriptDir & "\MMNewQuote.csv, ReadOnly:=1, LinkToSource:=1," _
                                     & "AddToRecentFiles:=0, " _
                                     & "PasswordDocument:='', PasswordTemplate:='', WritePasswordDocument:='', " _
                                                                         & "WritePasswordTemplate:='', Revert:=0, Format:=0," _
                                                                         & "Connection:='', SQLStatement:='', SQLStatement1:=''")
                                                                         



$mm.Execute

Thanks

Dougie

Link to comment
Share on other sites

  • Moderators

I have no way of testing it, but see if this works.

$oWord = ObjCreate("word.application")

With $oWord
    .visible = 1
    $oDoc = .documents.open (@ScriptDir & "\NewRateQuote.doc")
EndWith 

$oMailMerge = $oDoc.MailMerge
$oMailMerge.OpenDataSource ('"' & @ScriptDir & '\MMNewQuote.csv"', 0, True, True, True, False, "", "", False)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...