Hi,

New to vba so don't have much idea what I'm doing.

I'd like a userform that the user completes (form located on intraet), then emails the completed userform to predefined multiple users with a predefined subject.

I've created the userform, and it loads as an attachment, however when the recipient opens the attachment the form is reset and the entered values aren't there. I'm thinking it might be an initialize thing but really don't have a clue.

Also, if you get the urge, with the Private Sub txt_fw_Exit(ByVal cancel As MSForms.ReturnBoolean) the user has to hit 'cancel twice' instead of once.

Private Sub UserForm_Initialize()


'populates business and cost centre combo boxes
cmb_employer.AddItem "Avalon Property Group"
cmb_employer.AddItem "Media Six"
cmb_employer.AddItem "Bond (Gold Coast)"
cmb_employer.AddItem "Makbuild Homes"
cmb_employer.AddItem "North Brisbane Homes"
cmb_employer.AddItem "RB Douglas"
cmb_employer.AddItem "Port Macquarie"
cmb_employer.AddItem "Townsville"

cmb_costcentre.AddItem "Sales"
cmb_costcentre.AddItem "Construction Admin"
cmb_costcentre.AddItem "Management"
cmb_costcentre.AddItem "Finance&Admin"
cmb_costcentre.AddItem "Development"
cmb_costcentre.AddItem "Construction"
cmb_costcentre.AddItem "DesignBuild"
cmb_costcentre.AddItem "Home Expert Centre"
cmb_costcentre.AddItem "Windemere"


cmb_locn.AddItem "Office"
cmb_locn.AddItem "Display"
cmb_locn.AddItem "Home Expert Centre - SC"

cmb_emptype.AddItem "Full-time"
cmb_emptype.AddItem "Part-Time"
cmb_emptype.AddItem "Casual"
cmb_emptype.AddItem "Fixed term"
cmb_emptype.AddItem "Contractor"

cmb_buscards.AddItem ""
cmb_buscards.AddItem "250"
cmb_buscards.AddItem "500"
cmb_buscards.AddItem "1000"

End Sub


Private Sub chb_fw_change()
'this reveals/hides the framework (fw) 'same as who' text box

If chb_FW.Value = False Then
lb_fw.Visible = False
txt_fw.Visible = False

Else
lb_fw.Visible = True
txt_fw.Enabled = True
txt_fw.Visible = True
txt_fw.SetFocus

End If
End Sub

Private Sub txt_fw_Exit(ByVal cancel As MSForms.ReturnBoolean)
' this opens a message box where hitting 'ok' returns you to enter a name in the textbox, _
and cancel unchecks the checkbox and hides the textbox.

If txt_fw = "" Then

If MsgBox("You must enter a user profile to clone. Hit OK to enter a user name or cancel for no Framework access", _
vbOKCancel) = vbCancel Then

chb_FW.Value = False
cancel = False


Else

cancel = True

End If

End If

End Sub




Private Sub chb_tl_change()
'this reveals/hides the timberline (tl) 'same as who' text box
If chb_TL.Value = False Then
lb_TL.Visible = False
txt_TL.Visible = False

Else
lb_TL.Visible = True
txt_TL.Visible = True


End If


End Sub

Private Sub chb_drive_change()

If chb_drive.Value = True Then

txt_drive.Visible = True

Else

txt_drive.Visible = False

End If
End Sub

Private Sub cb1_Click()
Me.PrintForm
End Sub

Sub cb_2_click()

Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
Dim oSubject As String



On Error Resume Next

'Start Outlook if it isn't running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
End If



'Create a new message
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.Recipients.Add Name:="[email protected]"
.Recipients.Add Name:="[email protected]"
.subject = ("System Setup") & (" ") & txt_employee.Value
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
DisplayName:="Document as attachment"
End With

'Display the message
oItem.Display


'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
Set objInsp = Nothing
Set wdEditor = Nothing

End Sub