View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Setting OnAction of custom menu item?

Not tried this Ed, but if we just work it through. objWkbk is the object
variable in your VB app, which is totally meaningless to the commandbar and
its OnAction property. Running a macro in another workbook is in essence of
the form

Application.Run "myBook.xls'!myMacro"

so we need to build this up. All we have is an object and an implicit macro
name. We need the workbook name, which we can get from the object. So
something like

.OnAction = "'" & objWkbk.Name & "'!GetTIR"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ed" wrote in message
...
Found the error in this:
I set OnAction in the Visual
Basic app as
.OnAction = "objWkbk.Sheet1!GetTIR"
where "objWkbk" is the Excel file opened by the VB app. But when I run

the
macro in the workbook, I get the error "Can't find "objWkbk.Sheet1.xls".


Of course not! objWkbk is the *object* reference, not the *filename
string*! D'oh!

So I changed it. Now I get an error '400', whatever that means. The

macro
is there, and it does run when called. I just can't get this menu item to
call it.

Ed