Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
[email protected] dworst@gaic.com is offline
external usenet poster
 
Posts: 7
Default MS Word 2003 Case statement code

I've created a word form with 4 radio buttons on it and a command
button. Inside of my code for the button I want the button upon click
to evaluate which radio button is true and then perform a function.
Below is what I have so far but it doesn work correctly. Could anyone
guide me as to what I'm doing incorrectly?

Thanks so much!.

Sub SendDocumentAsAttachment2()
Dim vmailbox
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem


On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = New Outlook.Application
If Err 0 Then
Set oOutlookApp = New Outlook.Application
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

vmailbox = " "

Select Case Yes214.Value
Case True
vmailbox = "
End Select

Select Case Yes215.Value
Case True
vmailbox = "DL-GAI.ITServices.Database.Services"
End Select

Select Case Yes216.Value
Case True
vmailbox = "
End Select

Select Case Yes2141.Value
Case True
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
End Select

Select Case text13.Value
Case True
vmailbox = text13
Case Else
vmailbox = ""
End Select

With oItem
.To = vmailbox
.Subject = ActiveDocument.Name
'Add the document as an attachment, you can use the .displayname
property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
DisplayName:="Document as attachment"
.Display

End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default MS Word 2003 Case statement code

You only have 4 Option Buttons, but your code is "evaluating" 6 conditions.

After you sort out that inconsistency, use an If...ElseIf...Else...End If
construction as follows

Use

If Yes214.Value = True Then
vmailbox = "
ElseIf Yes215.Value = True Then
vmailbox = "DL-GAI.ITServices.Database.Services"
ElseIf Yes216.Value = True Then
vmailbox = "
Else Yes2141.Value = True Then 'If there are only 4 buttons and the first 3
are False, then this one must be True
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
End If


--
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

wrote in message
oups.com...
I've created a word form with 4 radio buttons on it and a command
button. Inside of my code for the button I want the button upon click
to evaluate which radio button is true and then perform a function.
Below is what I have so far but it doesn work correctly. Could anyone
guide me as to what I'm doing incorrectly?

Thanks so much!.

Sub SendDocumentAsAttachment2()
Dim vmailbox
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem


On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = New Outlook.Application
If Err 0 Then
Set oOutlookApp = New Outlook.Application
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

vmailbox = " "

Select Case Yes214.Value
Case True
vmailbox = "
End Select

Select Case Yes215.Value
Case True
vmailbox = "DL-GAI.ITServices.Database.Services"
End Select

Select Case Yes216.Value
Case True
vmailbox = "
End Select

Select Case Yes2141.Value
Case True
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
End Select

Select Case text13.Value
Case True
vmailbox = text13
Case Else
vmailbox = ""
End Select

With oItem
.To = vmailbox
.Subject = ActiveDocument.Name
'Add the document as an attachment, you can use the .displayname
property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
DisplayName:="Document as attachment"
.Display

End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
[email protected] dworst@gaic.com is offline
external usenet poster
 
Posts: 7
Default MS Word 2003 Case statement code

Doug:

Thanks for replying.

I have 4 Option Buttons and a text box so that is why it is evaluating
6 options. I didn't include that in my first email.

I put your code into my module, modifying it to fit the structure, but
even if the first condition Yes214.Value = True isn't true, it is
placing that email address in the To: field in my email. It doesn't go
past the first If statement.

What am I doing wrong???

Here is my code

Sub SendDocumentAsAttachment2()
Dim vmailbox
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem


On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = New Outlook.Application
If Err 0 Then
Set oOutlookApp = New Outlook.Application
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

vmailbox = " "

If Yes214.Value = True Then
vmailbox = "
If Yes215.Value = True Then
vmailbox = "DL-GAI.ITServices.Database.Services"
ElseIf Yes216.Value = True Then
vmailbox = "
ElseIf Yes2141.Value = True Then
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
ElseIf text13.Value = True Then
vmailbox = text13
Else
vmailbox = ""
End If

With oItem
.To = vmailbox
.Subject = ActiveDocument.Name
'Add the document as an attachment, you can use the .displayname
property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
DisplayName:="Document as attachment"
.Display

End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub


Doug Robbins - Word MVP wrote:
You only have 4 Option Buttons, but your code is "evaluating" 6 conditions.

After you sort out that inconsistency, use an If...ElseIf...Else...End If
construction as follows

Use

If Yes214.Value = True Then
vmailbox = "
ElseIf Yes215.Value = True Then
vmailbox = "DL-GAI.ITServices.Database.Services"
ElseIf Yes216.Value = True Then
vmailbox = "
Else Yes2141.Value = True Then 'If there are only 4 buttons and the first 3
are False, then this one must be True
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
End If


--
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

wrote in message
oups.com...
I've created a word form with 4 radio buttons on it and a command
button. Inside of my code for the button I want the button upon click
to evaluate which radio button is true and then perform a function.
Below is what I have so far but it doesn work correctly. Could anyone
guide me as to what I'm doing incorrectly?

Thanks so much!.

Sub SendDocumentAsAttachment2()
Dim vmailbox
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem


On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = New Outlook.Application
If Err 0 Then
Set oOutlookApp = New Outlook.Application
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

vmailbox = " "

Select Case Yes214.Value
Case True
vmailbox = "
End Select

Select Case Yes215.Value
Case True
vmailbox = "DL-GAI.ITServices.Database.Services"
End Select

Select Case Yes216.Value
Case True
vmailbox = "
End Select

Select Case Yes2141.Value
Case True
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
End Select

Select Case text13.Value
Case True
vmailbox = text13
Case Else
vmailbox = ""
End Select

With oItem
.To = vmailbox
.Subject = ActiveDocument.Name
'Add the document as an attachment, you can use the .displayname
property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
DisplayName:="Document as attachment"
.Display

End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
[email protected] dworst@gaic.com is offline
external usenet poster
 
Posts: 7
Default MS Word 2003 Case statement code

Doug:

Sorry, I had an error in my code, but it still doesn't work.

Sub SendDocumentAsAttachment2()
Dim vmailbox
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem


On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = New Outlook.Application
If Err 0 Then
Set oOutlookApp = New Outlook.Application
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

vmailbox = " "

If Yes214.Value = True Then
vmailbox = "
ElseIf Yes215.Value = True Then
vmailbox = "DL-GAI.ITServices.Database.Services"
ElseIf Yes216.Value = True Then
vmailbox = "
ElseIf Yes2141.Value = True Then
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
ElseIf text13.Value = True Then
vmailbox = text13
Else
vmailbox = ""
End If





With oItem
.To = vmailbox
.Subject = ActiveDocument.Name
'Add the document as an attachment, you can use the .displayname
property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
DisplayName:="Document as attachment"
.Display

End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub


wrote:
Doug:

Thanks for replying.

I have 4 Option Buttons and a text box so that is why it is evaluating
6 options. I didn't include that in my first email.

I put your code into my module, modifying it to fit the structure, but
even if the first condition Yes214.Value = True isn't true, it is
placing that email address in the To: field in my email. It doesn't go
past the first If statement.

What am I doing wrong???

Here is my code

Sub SendDocumentAsAttachment2()
Dim vmailbox
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem


On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = New Outlook.Application
If Err 0 Then
Set oOutlookApp = New Outlook.Application
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

vmailbox = " "

If Yes214.Value = True Then
vmailbox = "
If Yes215.Value = True Then
vmailbox = "DL-GAI.ITServices.Database.Services"
ElseIf Yes216.Value = True Then
vmailbox = "
ElseIf Yes2141.Value = True Then
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
ElseIf text13.Value = True Then
vmailbox = text13
Else
vmailbox = ""
End If

With oItem
.To = vmailbox
.Subject = ActiveDocument.Name
'Add the document as an attachment, you can use the .displayname
property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
DisplayName:="Document as attachment"
.Display

End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub


Doug Robbins - Word MVP wrote:
You only have 4 Option Buttons, but your code is "evaluating" 6 conditions.

After you sort out that inconsistency, use an If...ElseIf...Else...End If
construction as follows

Use

If Yes214.Value = True Then
vmailbox = "
ElseIf Yes215.Value = True Then
vmailbox = "DL-GAI.ITServices.Database.Services"
ElseIf Yes216.Value = True Then
vmailbox = "
Else Yes2141.Value = True Then 'If there are only 4 buttons and the first 3
are False, then this one must be True
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
End If


--
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

wrote in message
oups.com...
I've created a word form with 4 radio buttons on it and a command
button. Inside of my code for the button I want the button upon click
to evaluate which radio button is true and then perform a function.
Below is what I have so far but it doesn work correctly. Could anyone
guide me as to what I'm doing incorrectly?

Thanks so much!.

Sub SendDocumentAsAttachment2()
Dim vmailbox
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem


On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = New Outlook.Application
If Err 0 Then
Set oOutlookApp = New Outlook.Application
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

vmailbox = " "

Select Case Yes214.Value
Case True
vmailbox = "
End Select

Select Case Yes215.Value
Case True
vmailbox = "DL-GAI.ITServices.Database.Services"
End Select

Select Case Yes216.Value
Case True
vmailbox = "
End Select

Select Case Yes2141.Value
Case True
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
End Select

Select Case text13.Value
Case True
vmailbox = text13
Case Else
vmailbox = ""
End Select

With oItem
.To = vmailbox
.Subject = ActiveDocument.Name
'Add the document as an attachment, you can use the .displayname
property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
DisplayName:="Document as attachment"
.Display

End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub


  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default MS Word 2003 Case statement code

You still have a problem with trying to evaluate more items that there are
option buttons!

There is a very good chance that one of your option buttons will be true,
even if the user enters something into Text13 (which will not return the
Boolean value True in any event). This is because once one of the Option
buttons has been checked, there is no way that it can be unchecked.

I think you best plan might be to use a ComboBox containing the the first
four destinations, plus an item for "Enter Destination" and another one for
Do Nothing. The you evaluate what is selected in the ComboBox and if it is
the Enter Destination item, make the Textbox visible for the user to enter
the Destination.



--
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

wrote in message
ups.com...
Doug:

Sorry, I had an error in my code, but it still doesn't work.

Sub SendDocumentAsAttachment2()
Dim vmailbox
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem


On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = New Outlook.Application
If Err 0 Then
Set oOutlookApp = New Outlook.Application
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

vmailbox = " "

If Yes214.Value = True Then
vmailbox = "
ElseIf Yes215.Value = True Then
vmailbox = "DL-GAI.ITServices.Database.Services"
ElseIf Yes216.Value = True Then
vmailbox = "
ElseIf Yes2141.Value = True Then
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
ElseIf text13.Value = True Then
vmailbox = text13
Else
vmailbox = ""
End If





With oItem
.To = vmailbox
.Subject = ActiveDocument.Name
'Add the document as an attachment, you can use the .displayname
property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
DisplayName:="Document as attachment"
.Display

End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub


wrote:
Doug:

Thanks for replying.

I have 4 Option Buttons and a text box so that is why it is evaluating
6 options. I didn't include that in my first email.

I put your code into my module, modifying it to fit the structure, but
even if the first condition Yes214.Value = True isn't true, it is
placing that email address in the To: field in my email. It doesn't go
past the first If statement.

What am I doing wrong???

Here is my code

Sub SendDocumentAsAttachment2()
Dim vmailbox
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem


On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = New Outlook.Application
If Err 0 Then
Set oOutlookApp = New Outlook.Application
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

vmailbox = " "

If Yes214.Value = True Then
vmailbox = "
If Yes215.Value = True Then
vmailbox = "DL-GAI.ITServices.Database.Services"
ElseIf Yes216.Value = True Then
vmailbox = "
ElseIf Yes2141.Value = True Then
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
ElseIf text13.Value = True Then
vmailbox = text13
Else
vmailbox = ""
End If

With oItem
.To = vmailbox
.Subject = ActiveDocument.Name
'Add the document as an attachment, you can use the .displayname
property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
DisplayName:="Document as attachment"
.Display

End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub


Doug Robbins - Word MVP wrote:
You only have 4 Option Buttons, but your code is "evaluating" 6
conditions.

After you sort out that inconsistency, use an If...ElseIf...Else...End
If
construction as follows

Use

If Yes214.Value = True Then
vmailbox = "
ElseIf Yes215.Value = True Then
vmailbox = "DL-GAI.ITServices.Database.Services"
ElseIf Yes216.Value = True Then
vmailbox = "
Else Yes2141.Value = True Then 'If there are only 4 buttons and the
first 3
are False, then this one must be True
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
End If


--
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

wrote in message
oups.com...
I've created a word form with 4 radio buttons on it and a command
button. Inside of my code for the button I want the button upon
click
to evaluate which radio button is true and then perform a function.
Below is what I have so far but it doesn work correctly. Could
anyone
guide me as to what I'm doing incorrectly?

Thanks so much!.

Sub SendDocumentAsAttachment2()
Dim vmailbox
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem


On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = New Outlook.Application
If Err 0 Then
Set oOutlookApp = New Outlook.Application
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

vmailbox = " "

Select Case Yes214.Value
Case True
vmailbox = "
End Select

Select Case Yes215.Value
Case True
vmailbox = "DL-GAI.ITServices.Database.Services"
End Select

Select Case Yes216.Value
Case True
vmailbox = "
End Select

Select Case Yes2141.Value
Case True
vmailbox = "DL-GAI.ITServices.Info.Services.Informatica"
End Select

Select Case text13.Value
Case True
vmailbox = text13
Case Else
vmailbox = ""
End Select

With oItem
.To = vmailbox
.Subject = ActiveDocument.Name
'Add the document as an attachment, you can use the .displayname
property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
DisplayName:="Document as attachment"
.Display

End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 97 in Windows XP to maintain formatting Charlie''s Word VBA questions Microsoft Word Help 22 May 20th 23 08:51 PM
Why dont MS just f**king re-write Word from scratch? Its dogsh*t Word Hater Microsoft Word Help 33 May 5th 23 02:52 PM
Change paper size; Word changes to invalid margins OhioTech New Users 10 July 6th 06 02:00 PM
WP merge file to Word sstires Tables 4 February 14th 06 06:26 PM
Continuous breaks convert to next page breaks Jennifer Hunt Microsoft Word Help 2 December 30th 04 05:45 PM


All times are GMT +1. The time now is 07:32 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"