PC Review


Reply
Thread Tools Rate Thread

"ByRef argument type mismatch" error

 
 
Robert Crandal
Guest
Posts: n/a
 
      27th Dec 2009
I get the above stated compile error when I run the following code:

Dim myfile as String
myfile = "Book1.xlsm"

If Module1.IsWbOpen (myfile) Then
' Do stuff
End If

------------------[ IsWbOpen() is in Module1]--------------------

Public Function IsWbOpen(WbName As String) As Boolean
For Each wb In Application.Workbooks
If wb.Name = WbName Then
IsWbOpen = True
Exit For
End If
Next
End Function
--------------------------------------------------------------------


Does anybody know what the heck is wrong here??? I know i am
definitely passing a String variable into "IsWbOpen()", yet I am
seeing a compile error.

Thank you!


 
Reply With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      27th Dec 2009
Hi Robert,

I can't fault the code. It works perfectly. What line does the code stop on
when you get the error? You did copy your code from your project and not
re-write it for this post didn't you?

The error msge suggests that myfile is incorrectly declared as something
other than a string.

--
Regards,

OssieMac


"Robert Crandal" wrote:

> I get the above stated compile error when I run the following code:
>
> Dim myfile as String
> myfile = "Book1.xlsm"
>
> If Module1.IsWbOpen (myfile) Then
> ' Do stuff
> End If
>
> ------------------[ IsWbOpen() is in Module1]--------------------
>
> Public Function IsWbOpen(WbName As String) As Boolean
> For Each wb In Application.Workbooks
> If wb.Name = WbName Then
> IsWbOpen = True
> Exit For
> End If
> Next
> End Function
> --------------------------------------------------------------------
>
>
> Does anybody know what the heck is wrong here??? I know i am
> definitely passing a String variable into "IsWbOpen()", yet I am
> seeing a compile error.
>
> Thank you!
>
>
> .
>

 
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
"ByRef argument type mismtach" on string variable *sometimes* paul.domaskis@gmail.com Microsoft Excel Programming 3 4th Jun 2009 07:41 PM
"Compile Error: ByRef argument type mismatch" when calling my function from another module ker_01 Microsoft Excel Programming 2 14th Aug 2008 03:53 PM
HELP "ByRef Argument Type Mismatch" RocketMan Microsoft Excel Programming 6 7th Jun 2007 07:00 PM
ByRef argument type mismatch error? sermest Microsoft Excel Programming 4 17th Jun 2005 06:50 PM
ERROR: ByRef Argument Type Mismatch Chaster Microsoft Access VBA Modules 0 24th Jul 2003 11:15 PM


Features
 

Advertising
 

Newsgroups
 


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