Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Calling Function in Add-in

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Calling Function in Add-in

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Calling Function in Add-in

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Calling Function in Add-in

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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Calling Function in Add-in

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a function in my SQL-DB from VBA KSor Excel Discussion (Misc queries) 0 March 11th 09 02:08 PM
Calling a function Arne Hegefors Excel Programming 6 November 8th 07 05:30 PM
Calling VBA Function João Excel Programming 1 March 18th 07 04:34 AM
Calling Function mattsvai[_18_] Excel Programming 4 February 13th 06 10:49 PM
calling a function praptisahni Excel Programming 2 April 26th 04 05:17 PM


All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"