M
MarceepooNu
I'm trying to create a userform in Outlook 2003 vba, that will facilitate a
secretary creating an email message about telephone calls.
I get the following error message: Microsoft Office Access can't find the
form 'frmTelMsgInput01' referred to in a macro expression or Visual Basic Code
Any help figuring out how to fix this would be much appreciated.
Thanks,
marceepooNu
Here's the code:
'The following code resides in a userform (named: frmTelMsgInput01) in the
same Outlook project as the vba code below, which in turn resides in
ThisOutlookSession
Private Sub btnCreateEmail4TelMsg_Click()
' macro created on .2008.10.03. by marc
Dim frmTelMsgInput01 As Form
Dim txCallersName As TextBox
Dim txCaseName As TextBox
Dim btnCreateEmail4TelMsg As CommandButton
Dim sCallersName As String
Dim sCaseName As String
Set txCallersName = Forms!frmTelMsgInput01!txCallersName
Set txCaseName = Forms!frmTelMsgInput01!txCaseName
'Forms!frmTelMsgInput01!lblCallersName.SetFocus
sCallersName = txCallersName.text
sCaseName = txCaseName.text
Call ThisOutlookSession.TelMsg01Part02(sCallersName, sCaseName)
Set frmTelMsgInput01 = Nothing
Set txCallersName = Nothing
Set txCaseName = Nothing
Set btnCreateEmail4TelMsg = Nothing
End Sub
Private Sub frmTelMsgInput01_Initialize()
Load frmTelMsgInput01
frmTelMsgInput01.Show
End Sub
'-------------------------------------------------------------
'The following macro invokes the userform shown above
Sub TelMsg01Part01()
'End Sub
Dim appOL As Outlook.Application
Dim objMail As MailItem
Dim insActive As Outlook.Inspector
Dim itmMail As Outlook.MailItem
Dim sEmail As String
Dim sFormat As String
Dim sInputBoxMsg1, sInputBoxMsg2, sInputBoxMsgRet As String
Set appOL = CreateObject("Outlook.application")
Set objMail = Outlook.CreateItem(olMailItem)
Set insActive = appOL.ActiveInspector
Set itmMail = insActive.CurrentItem
With itmMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = sFormat
'"<HTML><H2>The body of this message will appear in
HTML.</H2><BODY>Type the message text here. </BODY></HTML>"
.Display
End With
objMail.Display
objMail.ShowCategoriesDialog
frmTelMsgInput01.Show
End Sub
'-------------------------------------------------------------
Sub TelMsg01Part02(ByVal sCallersName As String, ByVal sCaseName As String)
'sCallersName, sCaseName
'InputBox(prompt[, title] [, default] [, xpos] [, ypos] [, helpfile,
context])
'sInputBoxMsg1 = "Full name of caller (Please ask him/her to spell it
unless you're absolutely certain of the spelling"
'sInputBoxMsgRet = InputBox(sInputBoxMsg1, "Caller's name & Date/Time of
Call")
sFormat = "<HTML>" & CStr(Now) & " " & _
" <strong>Caller's Full Name:</strong> " & sCallersName & _
" Re <strong>Case:</strong> " & sCaseName & _
"<br>" & vbCrLf & _
vbCrLf & _
"<br>If the caller is listed in ContactsForOfc, THEN: CLICK:
'Options', 'Contacts, " & _
" 'Folders', 'All Public Folders', 'Contacts4Ofc', and THEN
SELECT the contact. (Whew!!)<br>" & _
vbCrLf & _
"<br>If the caller is NOT listed in ContactsForOfc, please get
the following info:<br>" & vbCrLf & _
"<BLOCKQUOTE dir=ltr style=" & Chr(34) & "MARGIN-RIGHT: 0px>" &
Chr(34) & _
"Bus.Tel. <br>" & _
" Bus.Tel. <br>" & vbCrLf & _
" Cell.Tel. <br>" & vbCrLf & _
" Hom.Tel. <br>" & vbCrLf & _
" Fax.Tel. <br>" & vbCrLf & _
" Address: Street & Apt/Ste No. <br>" & vbCrLf & _
" City, State & Zip: <br><br></BLOCKQUOTE>" & vbCrLf &
vbCrLf & _
"<strong>[Please read this text to the caller: </strong>" & _
"<BLOCKQUOTE dir=ltr style=" & Chr(34) & "MARGIN-RIGHT: 0px>" &
Chr(34) & _
" Mr. Hankin asked me to request convenient times of day
when he may return your call.<br>" & _
" Mr. Hankin asked me to emphasize that he wants times of
day when you will be somewhere<br>" & _
" anyway, so that you won't be inconvenienced if some emergency
prevents him from<br>" & _
" returning your call at the expected
time.]<br><br></BLOCKQUOTE>" & vbCrLf & vbCrLf & _
" Message: </HTML>"
With itmMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = sFormat
'"<HTML><H2>The body of this message will appear in
HTML.</H2><BODY>Type the message text here. </BODY></HTML>"
.Display
End With
itmMail.Subject = "Tcf: " & sCallersName & " " & CStr(Now) & " Re
Case: " & sCaseName
itmMail.To = "(e-mail address removed)"
' 'This adds the text to the END of the existing message
'sEmail = itmMail.Body
' 'Add a vbcrlf before the boilerplate text
'sEmail = sEmail & sFormat & vbCrLf
'
'itmMail.Body = sEmail
' objEmail.Body.PrintText text:="Please find table below :-"
' objEmail.Body.PrintParagraph
'' wdRn.Paste ' to paste in the Word Range
' objEmail.Body.PrintParagraph
' objEmail.Body.PrintText text:="Regards etc."
End Sub
'
secretary creating an email message about telephone calls.
I get the following error message: Microsoft Office Access can't find the
form 'frmTelMsgInput01' referred to in a macro expression or Visual Basic Code
Any help figuring out how to fix this would be much appreciated.
Thanks,
marceepooNu
Here's the code:
'The following code resides in a userform (named: frmTelMsgInput01) in the
same Outlook project as the vba code below, which in turn resides in
ThisOutlookSession
Private Sub btnCreateEmail4TelMsg_Click()
' macro created on .2008.10.03. by marc
Dim frmTelMsgInput01 As Form
Dim txCallersName As TextBox
Dim txCaseName As TextBox
Dim btnCreateEmail4TelMsg As CommandButton
Dim sCallersName As String
Dim sCaseName As String
Set txCallersName = Forms!frmTelMsgInput01!txCallersName
Set txCaseName = Forms!frmTelMsgInput01!txCaseName
'Forms!frmTelMsgInput01!lblCallersName.SetFocus
sCallersName = txCallersName.text
sCaseName = txCaseName.text
Call ThisOutlookSession.TelMsg01Part02(sCallersName, sCaseName)
Set frmTelMsgInput01 = Nothing
Set txCallersName = Nothing
Set txCaseName = Nothing
Set btnCreateEmail4TelMsg = Nothing
End Sub
Private Sub frmTelMsgInput01_Initialize()
Load frmTelMsgInput01
frmTelMsgInput01.Show
End Sub
'-------------------------------------------------------------
'The following macro invokes the userform shown above
Sub TelMsg01Part01()
'End Sub
Dim appOL As Outlook.Application
Dim objMail As MailItem
Dim insActive As Outlook.Inspector
Dim itmMail As Outlook.MailItem
Dim sEmail As String
Dim sFormat As String
Dim sInputBoxMsg1, sInputBoxMsg2, sInputBoxMsgRet As String
Set appOL = CreateObject("Outlook.application")
Set objMail = Outlook.CreateItem(olMailItem)
Set insActive = appOL.ActiveInspector
Set itmMail = insActive.CurrentItem
With itmMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = sFormat
'"<HTML><H2>The body of this message will appear in
HTML.</H2><BODY>Type the message text here. </BODY></HTML>"
.Display
End With
objMail.Display
objMail.ShowCategoriesDialog
frmTelMsgInput01.Show
End Sub
'-------------------------------------------------------------
Sub TelMsg01Part02(ByVal sCallersName As String, ByVal sCaseName As String)
'sCallersName, sCaseName
'InputBox(prompt[, title] [, default] [, xpos] [, ypos] [, helpfile,
context])
'sInputBoxMsg1 = "Full name of caller (Please ask him/her to spell it
unless you're absolutely certain of the spelling"
'sInputBoxMsgRet = InputBox(sInputBoxMsg1, "Caller's name & Date/Time of
Call")
sFormat = "<HTML>" & CStr(Now) & " " & _
" <strong>Caller's Full Name:</strong> " & sCallersName & _
" Re <strong>Case:</strong> " & sCaseName & _
"<br>" & vbCrLf & _
vbCrLf & _
"<br>If the caller is listed in ContactsForOfc, THEN: CLICK:
'Options', 'Contacts, " & _
" 'Folders', 'All Public Folders', 'Contacts4Ofc', and THEN
SELECT the contact. (Whew!!)<br>" & _
vbCrLf & _
"<br>If the caller is NOT listed in ContactsForOfc, please get
the following info:<br>" & vbCrLf & _
"<BLOCKQUOTE dir=ltr style=" & Chr(34) & "MARGIN-RIGHT: 0px>" &
Chr(34) & _
"Bus.Tel. <br>" & _
" Bus.Tel. <br>" & vbCrLf & _
" Cell.Tel. <br>" & vbCrLf & _
" Hom.Tel. <br>" & vbCrLf & _
" Fax.Tel. <br>" & vbCrLf & _
" Address: Street & Apt/Ste No. <br>" & vbCrLf & _
" City, State & Zip: <br><br></BLOCKQUOTE>" & vbCrLf &
vbCrLf & _
"<strong>[Please read this text to the caller: </strong>" & _
"<BLOCKQUOTE dir=ltr style=" & Chr(34) & "MARGIN-RIGHT: 0px>" &
Chr(34) & _
" Mr. Hankin asked me to request convenient times of day
when he may return your call.<br>" & _
" Mr. Hankin asked me to emphasize that he wants times of
day when you will be somewhere<br>" & _
" anyway, so that you won't be inconvenienced if some emergency
prevents him from<br>" & _
" returning your call at the expected
time.]<br><br></BLOCKQUOTE>" & vbCrLf & vbCrLf & _
" Message: </HTML>"
With itmMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = sFormat
'"<HTML><H2>The body of this message will appear in
HTML.</H2><BODY>Type the message text here. </BODY></HTML>"
.Display
End With
itmMail.Subject = "Tcf: " & sCallersName & " " & CStr(Now) & " Re
Case: " & sCaseName
itmMail.To = "(e-mail address removed)"
' 'This adds the text to the END of the existing message
'sEmail = itmMail.Body
' 'Add a vbcrlf before the boilerplate text
'sEmail = sEmail & sFormat & vbCrLf
'
'itmMail.Body = sEmail
' objEmail.Body.PrintText text:="Please find table below :-"
' objEmail.Body.PrintParagraph
'' wdRn.Paste ' to paste in the Word Range
' objEmail.Body.PrintParagraph
' objEmail.Body.PrintText text:="Regards etc."
End Sub
'