Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default "ByRef argument type mismtach" on string variable *sometimes*

I am using the code at http://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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default "ByRef argument type mismtach" on string variable *sometimes*

Here is the test code with the troublesome code highlighted. The
Excel file must have a spreadsheet with tab name "Test".

Option Explicit

Public Sub Aggregate()

Dim TargetString, OtherString As String
Dim SomeCell As Range
Dim ColorIndexRed As Integer

ColorIndexRed = 3
Set SomeCell = Sheets("Test").Range("A1")
TargetString = "QuickBrownFox"

' Troublesome code
'-------------------
'Call xlCellTextMgmt(SomeCell, _
' TargetString, , , , , ColorIndexRed)

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

OtherString = "QuickBrownFox"
SomeCell = OtherString

Call xlCellTextMgmt(SomeCell, _
OtherString, , , , , ColorIndexRed)

End Sub

---------- Forwarded message ----------
From:
Date: Jun 3, 3:13*pm
Subject: "ByRef argument type mismtach" on string variable *sometimes*
To: microsoft.public.excel.programming


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?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default "ByRef argument type mismtach" on string variable *sometimes*

Here is the test code with the troublesome code highlighted. The
Excel file must have a spreadsheet with tab name "Test".

Option Explicit

Public Sub Aggregate()

Dim TargetString, OtherString As String
Dim SomeCell As Range
Dim ColorIndexRed As Integer

ColorIndexRed = 3
Set SomeCell = Sheets("Test").Range("A1")
TargetString = "QuickBrownFox"

' Troublesome code
'-------------------
'Call xlCellTextMgmt(SomeCell, _
' TargetString, , , , , ColorIndexRed)

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

OtherString = "QuickBrownFox"
SomeCell = OtherString

Call xlCellTextMgmt(SomeCell, _
OtherString, , , , , ColorIndexRed)

End Sub

---------- Forwarded message ----------
From:
Date: Jun 3, 3:13*pm
Subject: "ByRef argument type mismtach" on string variable *sometimes*
To: microsoft.public.excel.programming


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?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default "ByRef argument type mismtach" on string variable *sometimes*

TargetString is a Variant and the called function is expecting a String...

Dim TargetString as String
Dim OtherString as String
--
Jim Cone
Portland, Oregon USA

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default "ByRef argument type mismtach" on string variable *sometimes*

TargetString is a Variant and the called function is expecting a String...

Dim TargetString as String
Dim OtherString as String
--
Jim Cone
Portland, Oregon USA



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default "ByRef argument type mismtach" on string variable *sometimes*

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 at http://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?


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default "ByRef argument type mismtach" on string variable *sometimes*

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 at http://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?


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default "ByRef argument type mismtach" on string variable *sometimes*

On Jun 3, 3:34*pm, "Jim Cone" wrote:
TargetString is a Variant and the called function is expecting a String....

Dim TargetString as String
Dim OtherString as String


Thanks, Jim. I need to read the Help more carefully (though
admittedly, this behaviour does depart from many other languages).
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default "ByRef argument type mismtach" on string variable *sometimes*

On Jun 3, 3:34*pm, "Jim Cone" wrote:
TargetString is a Variant and the called function is expecting a String....

Dim TargetString as String
Dim OtherString as String


Thanks, Jim. I need to read the Help more carefully (though
admittedly, this behaviour does depart from many other languages).
  #10   Report Post  
Posted to microsoft.public.excel.programming
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 -




  #11   Report Post  
Posted to microsoft.public.excel.programming
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 -


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
"Compile Error: ByRef argument type mismatch" when calling my function from another module ker_01 Excel Programming 2 August 14th 08 03:53 PM
ByRef Argument Type Mismatch Sprinks Excel Programming 5 August 8th 08 04:11 PM
HELP "ByRef Argument Type Mismatch" RocketMan[_2_] Excel Programming 6 June 7th 07 07:00 PM
"Type mismatch" when I try to fill an Array variable with "+" [email protected] Excel Discussion (Misc queries) 1 April 17th 07 01:28 PM
"ByRef argument type mismatch" Error Baapi[_4_] Excel Programming 2 September 17th 05 12:47 AM


All times are GMT +1. The time now is 03:18 AM.

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

About Us

"It's about Microsoft Excel"