cancel
Showing results for 
Search instead for 
Did you mean: 

Execute Macro with Parameter

Former Member
0 Kudos

Hi,

can anyone tell me how can I call a Macro in Worddocument with parameter. I'm trying to insert some MergeFields in needed Position using following marco.

Sub MailMerge(Name As String)

' Add the merge field.

ActiveDocument.MailMerge.Fields.Add _

Range:=Selection.Range, _

Name:=Name

End Sub

and then running this macro in program like this:

call method of wordobj 'MailMergeOpenDataSource'...

call method of wordobj 'MailMergeEditMainDocument' ....

call method of wordobj 'TableInsertTable'...

loop at fields.

call method of wordobj 'NextCell'.

call method of wordobj 'Insert'

exporting

#1 = fields-label.

call method of wordobj 'NextCell'.

call method of wordobj 'ToolsMacro'

exporting #1 = 'MailMerge' " <-- Makroname

#2 = 1 " <-- Run

#??? = Parameter.

endloop.

Thanks a lot.

regards,

sumiya

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_brutigam2
Active Participant
0 Kudos

Hi sumiya

The syntax is as Following:


Application Run Makroname,par1,par2,...

For example


Apllication.Run "mailmerge", "Test1", "e-mail@" ...

greetings

Thomas Br