PC Review


Reply
Thread Tools Rate Thread

Calling Function in Add-in

 
 
MikeH2
Guest
Posts: n/a
 
      25th Feb 2008
In a VBA Sub, I issue this command:

Dim IsItOpen As Variant
IsItOpen = Application.Run("personal.xla!IsOpenWB", "chart of accounts.xlsx")

And the function in personal.xla is:
Public Function isopenwb(ByVal WBname As String) As Boolean
'returns true if workbook is open
Dim objWorkbook As Object
On Error Resume Next
isopenwb = False
Set objWorkbook = Workbooks(WBname)
If Err = 0 Then isopenwb = True
End Function

But I get an error, "The Macro 'personal.xla!IsOpenWB' cannot be found.
Ideas?
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      25th Feb 2008
It sounds like personal.xla isn't open.

Or maybe IsOpenWB isn't in a general module.



MikeH2 wrote:
>
> In a VBA Sub, I issue this command:
>
> Dim IsItOpen As Variant
> IsItOpen = Application.Run("personal.xla!IsOpenWB", "chart of accounts.xlsx")
>
> And the function in personal.xla is:
> Public Function isopenwb(ByVal WBname As String) As Boolean
> 'returns true if workbook is open
> Dim objWorkbook As Object
> On Error Resume Next
> isopenwb = False
> Set objWorkbook = Workbooks(WBname)
> If Err = 0 Then isopenwb = True
> End Function
>
> But I get an error, "The Macro 'personal.xla!IsOpenWB' cannot be found.
> Ideas?


--

Dave Peterson
 
Reply With Quote
 
MikeH2
Guest
Posts: n/a
 
      25th Feb 2008
Personal.xla is open and the module type pulldown at the top says (General)

"Dave Peterson" wrote:

> It sounds like personal.xla isn't open.
>
> Or maybe IsOpenWB isn't in a general module.
>
>
>
> MikeH2 wrote:
> >
> > In a VBA Sub, I issue this command:
> >
> > Dim IsItOpen As Variant
> > IsItOpen = Application.Run("personal.xla!IsOpenWB", "chart of accounts.xlsx")
> >
> > And the function in personal.xla is:
> > Public Function isopenwb(ByVal WBname As String) As Boolean
> > 'returns true if workbook is open
> > Dim objWorkbook As Object
> > On Error Resume Next
> > isopenwb = False
> > Set objWorkbook = Workbooks(WBname)
> > If Err = 0 Then isopenwb = True
> > End Function
> >
> > But I get an error, "The Macro 'personal.xla!IsOpenWB' cannot be found.
> > Ideas?

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      25th Feb 2008
That's not enough information.

Is the code in the ThisWorkbook module? Or behind a worksheet?

Select your project in the project explorer in the VBE and click on
Insert|Module.

Then move (not copy) your code there.

MikeH2 wrote:
>
> Personal.xla is open and the module type pulldown at the top says (General)
>
> "Dave Peterson" wrote:
>
> > It sounds like personal.xla isn't open.
> >
> > Or maybe IsOpenWB isn't in a general module.
> >
> >
> >
> > MikeH2 wrote:
> > >
> > > In a VBA Sub, I issue this command:
> > >
> > > Dim IsItOpen As Variant
> > > IsItOpen = Application.Run("personal.xla!IsOpenWB", "chart of accounts.xlsx")
> > >
> > > And the function in personal.xla is:
> > > Public Function isopenwb(ByVal WBname As String) As Boolean
> > > 'returns true if workbook is open
> > > Dim objWorkbook As Object
> > > On Error Resume Next
> > > isopenwb = False
> > > Set objWorkbook = Workbooks(WBname)
> > > If Err = 0 Then isopenwb = True
> > > End Function
> > >
> > > But I get an error, "The Macro 'personal.xla!IsOpenWB' cannot be found.
> > > Ideas?

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
MikeH2
Guest
Posts: n/a
 
      25th Feb 2008
It is in a module by itself now. It never was part of the Microsoft Excel
Objects. It was always a module. Now it is in Module1 (as I usually rename
modules). But I believe I have other copies of that function elsewhere so I
renamed it to IsOpenWBXX and called it thusly and it works. So I believe it
must be a 'matter of mistaken identity' of my function. Anyway, issue
resolved short-term and I will fix long-term by cleaning up my code and
eliminated dup functions with the same name.

"Dave Peterson" wrote:

> That's not enough information.
>
> Is the code in the ThisWorkbook module? Or behind a worksheet?
>
> Select your project in the project explorer in the VBE and click on
> Insert|Module.
>
> Then move (not copy) your code there.
>
> MikeH2 wrote:
> >
> > Personal.xla is open and the module type pulldown at the top says (General)
> >
> > "Dave Peterson" wrote:
> >
> > > It sounds like personal.xla isn't open.
> > >
> > > Or maybe IsOpenWB isn't in a general module.
> > >
> > >
> > >
> > > MikeH2 wrote:
> > > >
> > > > In a VBA Sub, I issue this command:
> > > >
> > > > Dim IsItOpen As Variant
> > > > IsItOpen = Application.Run("personal.xla!IsOpenWB", "chart of accounts.xlsx")
> > > >
> > > > And the function in personal.xla is:
> > > > Public Function isopenwb(ByVal WBname As String) As Boolean
> > > > 'returns true if workbook is open
> > > > Dim objWorkbook As Object
> > > > On Error Resume Next
> > > > isopenwb = False
> > > > Set objWorkbook = Workbooks(WBname)
> > > > If Err = 0 Then isopenwb = True
> > > > End Function
> > > >
> > > > But I get an error, "The Macro 'personal.xla!IsOpenWB' cannot be found.
> > > > Ideas?
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Method of calling a function where function name is stored in a variable or control Tony Vrolyk Microsoft Access VBA Modules 9 12th Jul 2007 07:20 PM
Method of calling a function where function name is stored in a variable or control Bob Quintal Microsoft Access 2 11th Jul 2007 08:49 PM
Calling EXE Function Getting handle to calling exe Abhishek Microsoft VC .NET 1 25th Sep 2006 01:58 PM
Calling managed function from unmanaged function in mixed mode dll slugster@gmail.com Microsoft VC .NET 1 25th Jul 2005 07:30 AM
Calling DoCmd.RunCommand acCmdSaveRecord, after calling an API function Savvoulidis Iordanis Microsoft Access Form Coding 2 19th Mar 2005 06:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:17 PM.