Can't run another sub from If...Then?

D

David

Hi,

I'm using Word 2000(9.0.2720) on XP Pro.

Looking to branch from a sub to another sub based on the value of a
variable, so the code is:
Sub IAorICC()
If vWT = "L" Then InsertAddress
If vWT = "N" Then InsertCC
End Sub
Won't run the sub 'InsertAddress'. What do I do to get it to work, please?

Thank you
 
G

Graham Mayor

Does this macro know what the variable vWT is? It doesn't from the code you
have supplied, so the conditions would never be true

What does the message box show?.

Sub IAorICC()
MsgBox vWT
If vWT = "L" Then InsertAddress
If vWT = "N" Then InsertCC
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

David

Thank you, Yes.
vWT As String was DIMmed as public in the declarations. The previous sub set
the value of vWT. The msgbox was there to confirm and showed the value L as
it should.

I took your idea and put the msgbox into the If and it failed.
So the problem isnt running the sub, the problem IS that the 'If...Then'
isnt recognizing the value of vWT.
I tried:
If vWT = "L" then...
and
If vWT = L then...
unsuccessfully.
 
D

Doug Robbins - Word MVP

As running

Dim vWT As String
vWT = "L"
If vWT = "L" Then
MsgBox vWT
End If

Causes L to be displayed in a message box, if the following does not work,

If vWT = "L" Then
InsertAddress
Else
InsertCC
End If

there is something wrong with InsertAddress and/or InsertCC


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top