PDA

View Full Version : Application.Run Method in VBA



sunaxis
03-11-2006, 11:45 AM
Hi, I have tried run macro that is placed in Normal.dot template from Access VBA code but it doesn't work.
VBA returns error: Object doesn't support this property or method.

Code in Access:


WFile = Application.CurrentProject.Path & "\MailLabels.doc"
DBname = Application.CurrentProject.FullName
Connect = "TABLE tblCustomers"
'Open connection to Word and make Word visible.
Set myWDApp = CreateObject("Word.Application")
myWDApp.Application.Visible = True
'Run mailing label procedure.
myWDApp.Application.Run "Normal.modHC.WMailLabels", WFile, DBname, Connect

Called procedure in Word Normal.dot Module:


Public Sub WMailLabels(strWFileName As String, strDBname As String, strConnectTo As String)
Dim myDoc As Document
'Set reference to the document
Documents.Open FileName:=strWFileName
'etc.....

When called procedure in Word hasn't arguments, it's all right.
What can be wrong?

TonyJollans
03-11-2006, 06:34 PM
I haven't checked whether this will make a difference but all you should need is ...

myWDApp.Run

The extra "Application" is, at best, redundant.

sunaxis
03-12-2006, 10:42 AM
Thanx,
but unfortunately it doesn't solve my problem.
It seems to me that Run Method doesn't receive any arguments.
There is no mention about it in the VBA Help.:dunno

Norie
03-12-2006, 11:17 AM
This is from the Run topic of VBA Help.


Run Method

Runs a Visual Basic macro.

Syntax

expression.Run(MacroName, varg1, varg2, varg3, varg4, varg5, varg6, varg7, varg8, varg9, varg10, varg11, varg12, varg13, varg14, varg15, varg16, varg17, varg18, varg19, varg20, varg21, varg22, varg23, varg24, varg25, varg26, varg27, varg28, varg29, varg30)

varg1...varg30 Optional Variant. Macro parameter values. You can pass up to 30 parameter values to the specified macro.

sunaxis
03-13-2006, 10:49 AM
I meant to say there is no mention about such error in the VBA helpthat Run Method shouldn't receive any arguments.

TonyJollans
03-13-2006, 03:15 PM
Hi sunaxis,

There is no reason I know for this not to work - but it doesn't work for me either. If I find anything I'll post back.

sunaxis
03-14-2006, 09:49 AM
Hi Tony,
I thank you for your interest. I'll search too.

sa