View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
[email protected] paul.domaskis@gmail.com is offline
external usenet poster
 
Posts: 41
Default "ByRef argument type mismtach" on string variable *sometimes*

Thank you for that, RB.

On Jun 3, 3:40*pm, "RB Smissaert"
wrote:
You need to declare TargetString as String, so:

Dim TargetString As String
Dim OtherString As String

When you do:
Dim TargetString, OtherString As String

Then TargetString is declared as a Variant.

The other options are to pass TargetString ByVal or do Cstr(TargetString)

RBS

wrote in message

...



I am using the code athttp://www.vbaexpress.com/kb/archive.php/k-743.html
to change the color of some text in an Excel 2003 spreadsheet. *I am
using the following type of invocation:


Dim TargetString, OtherString As String
TargetString = "QuickBrownFox"
Call xlCellTextMgmt( SomeCell, _
* TargetString , , , , , ColorIndexRed )


This generates the error in the subject line. *However, this
invocation is fine:


Call xlCellTextMgmt( SomeCell, _
* "QuickBrownFox", , , , , ColorIndexRed )


This invocation is fine, too:


OtherString = "QuickBrownFox"
SomeCell = OtherString
Call xlCellTextMgmt( SomeCell, _
* OtherString, , , , , ColorIndexRed )


What could possibly cause the first invocation to give the subject
error?- Hide quoted text -


- Show quoted text -