String not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Set myRequiredAttendee = myItem.Recipients.Add("" & strto3
myRequiredAttendee.Type = strto
Set myOptionalAttendee = myItem.Recipients.Add("" & strto4
myOptionalAttendee.Type = strto
myItem.Displa

The strto1 value is coming into this part of my routine but is stopping. I am getting a type mismatch. How should this be written

TIA
 
What type of object are we dealing with here, and what is in strto1?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Greg said:
Set myRequiredAttendee = myItem.Recipients.Add("" & strto3)
myRequiredAttendee.Type = strto1
Set myOptionalAttendee = myItem.Recipients.Add("" & strto4)
myOptionalAttendee.Type = strto2
myItem.Display

The strto1 value is coming into this part of my routine but is stopping. I
am getting a type mismatch. How should this be written?
 
Bob
stroto1 is a value that is comeing from a checkbox. It is either oloptional or olrequried. Am I trying to make this work but have no hope? I don't think so because when I look at the script it has the var. value from the sheck box. Should I post the whole routine? Let me know

TI

----- Bob Phillips wrote: ----

What type of object are we dealing with here, and what is in strto1

--

HT

Bob Phillip
... looking out across Poole Harbour to the Purbeck
(remove nothere from the email address if mailing direct
 
Greg,

I think it would help to see all the code.Presumably we are talking Outlook
mail here?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Greg said:
Bob,
stroto1 is a value that is comeing from a checkbox. It is either
oloptional or olrequried. Am I trying to make this work but have no hope? I
don't think so because when I look at the script it has the var. value from
the sheck box. Should I post the whole routine? Let me know.
 
Bob, we are...... looking at outloo

Private Sub checkbox1_Click(
With Me.CheckBox
If Me.CheckBox1.Value = True The
CheckBox1.Caption = "Required
strto1 = "olrequired
Els
Me.CheckBox1 = Fals
CheckBox1.Caption = "Optional
strto1 = "
End I
End Wit
End Su

Private Sub checkbox2_click(
With Me.CheckBox
If Me.CheckBox2.Value = True The
CheckBox2.Caption = "Required
strto2 = "olrequired
Els
Me.CheckBox2 = Fals
CheckBox2.Caption = "Optional
strto2 = "
End I
End Wit
End Su
Private Sub meeting() 'this code sets the meeting page
'On Error GoTo line

Set myOlApp = CreateObject("Outlook.Application") 'triggers O
Set myItem = myOlApp.CreateItem(olAppointmentItem) 'trigger meeting reques

myItem.MeetingStatus = olMeeting 'triggers the abaility to set the meeeting event
myItem.Subject = "Strategy Meeting
myItem.Location = "TBD
myItem.Start = #3/21/1997 1:30:00 PM
myItem.Duration = 9
Set myRequiredAttendee = myItem.Recipients.Add("" & strto3
myRequiredAttendee.Type = strto
Set myOptionalAttendee = myItem.Recipients.Add("" & strto4
myOptionalAttendee.Type = strto
myItem.Displa
'line1
End Su
 
Hi Greg,

Okay, now I can see the problem.

First though a question. Are you setting a reference to the Outlook library
in Tools>Reference? I assume you are because you are using the Outlook
constants olAppointItem and olMeeting in the Meeting routine, but I also
note that you use CreateObject which is normally used for not having a
defence set-up.

In essence, the problem comes from setting strto1 and strto2 to string
variables, and then trying to use these string variable to set a meeting
type, which is a Long, hence you get a Type mismatch. This can be easily
cured, depending upon the answer to my question.

If you have set a reference, change the checkbox code to

Private Sub checkbox1_Click()
With Me.CheckBox1
If Me.CheckBox1.Value = True Then
CheckBox1.Caption = "Required"
strto1 = olRequired
Else
Me.CheckBox1 = False
CheckBox1.Caption = "Optional"
strto1 = olOptional
End If
End With
End Sub

and similarly for Checkbox2. Your code doesn't show it, but if you declare
the variables strto1 and strto2, ensure that they are declared as type
olMeetingRecipientType.

If you have not set a defence, then change the checkbox code to

Private Sub checkbox1_Click()
With Me.CheckBox1
If Me.CheckBox1.Value = True Then
CheckBox1.Caption = "Required"
strto1 = 1
Else
Me.CheckBox1 = False
CheckBox1.Caption = "Optional"
strto1 = 2
End If
End With
End Sub

and similarly for Checkbox2. Your code doesn't show it, but if you declare
the variables strto1 and strto2, ensure that they are declared as type
variant.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Bob
I can't really answer your question. I did it that way because it worked. In reference to the create object. When I declared the strto I did it this way
Public strto1 As Strin
Public strto2 As Strin
Public strto3 As Strin
Public strto4 As Strin

Should I declare them diffreently? I also think that I may be writing something that is slightly out of my league but I will keep trying. I really don't think that I have answered your question correctly

Thank
Gre
----- Bob Phillips wrote: ----

Hi Greg

Okay, now I can see the problem

First though a question. Are you setting a reference to the Outlook librar
in Tools>Reference? I assume you are because you are using the Outloo
constants olAppointItem and olMeeting in the Meeting routine, but I als
note that you use CreateObject which is normally used for not having
defence set-up

In essence, the problem comes from setting strto1 and strto2 to strin
variables, and then trying to use these string variable to set a meetin
type, which is a Long, hence you get a Type mismatch. This can be easil
cured, depending upon the answer to my question

If you have set a reference, change the checkbox code t

Private Sub checkbox1_Click(
With Me.CheckBox
If Me.CheckBox1.Value = True The
CheckBox1.Caption = "Required
strto1 = olRequire
Els
Me.CheckBox1 = Fals
CheckBox1.Caption = "Optional
strto1 = olOptiona
End I
End Wit
End Su

and similarly for Checkbox2. Your code doesn't show it, but if you declar
the variables strto1 and strto2, ensure that they are declared as typ
olMeetingRecipientType

If you have not set a defence, then change the checkbox code t

Private Sub checkbox1_Click(
With Me.CheckBox
If Me.CheckBox1.Value = True The
CheckBox1.Caption = "Required
strto1 =
Els
Me.CheckBox1 = Fals
CheckBox1.Caption = "Optional
strto1 =
End I
End Wit
End Su

and similarly for Checkbox2. Your code doesn't show it, but if you declar
the variables strto1 and strto2, ensure that they are declared as typ
variant

--

HT

Bob Phillip
... looking out across Poole Harbour to the Purbeck
(remove nothere from the email address if mailing direct
 
Greg,

It doesn't really matter why you did it that way, or even which way you did
it, as I tried to answer both possibilities. The reason that I asked is that
if you did add a reference to the Outlook library (via Tools>References, and
I think you did as you user the Outlook constants olAppointItem and
olMeeting in the Meeting routine) then we can continue to use other
constants.

I am a stroing advocate of typing variables, but in this case, as you seem
unsure of what you are doing, and how to get it to work, I suggest that you
declare those variab les as such

Public strto1
Public strto2
Public strto3 As String
Public strto4 As String

and change the two checkbox routines to this

Private Sub checkbox1_Click()
With Me.CheckBox1
If Me.CheckBox1.Value = True Then
CheckBox1.Caption = "Required"
strto1 = olRequired
Else
Me.CheckBox1 = False
CheckBox1.Caption = "Optional"
strto1 = olOptional
End If
End With
End Sub

Private Sub checkbox2_Click()
With Me.CheckBox2
If Me.CheckBox2.Value = True Then
CheckBox2.Caption = "Required"
strto2 = olRequired
Else
Me.CheckBox2 = False
CheckBox2.Caption = "Optional"
strto2 = olOptional
End If
End With
End Sub

Give it a try, it should work.


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Greg said:
Bob,
I can't really answer your question. I did it that way because it
worked. In reference to the create object. When I declared the strto I did
it this way
Public strto1 As String
Public strto2 As String
Public strto3 As String
Public strto4 As String

Should I declare them diffreently? I also think that I may be writing
something that is slightly out of my league but I will keep trying. I
really don't think that I have answered your question correctly.
 

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

Back
Top