![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 '"HTMLH2The body of this message will appear in HTML./H2BODYType 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) & " " & _ " strongCaller's Full Name:/strong " & sCallersName & _ " Re strongCase:/strong " & sCaseName & _ "br" & vbCrLf & _ vbCrLf & _ "brIf the caller is listed in ContactsForOfc, THEN: CLICK: 'Options', 'Contacts, " & _ " 'Folders', 'All Public Folders', 'Contacts4Ofc', and THEN SELECT the contact. (Whew!!)br" & _ vbCrLf & _ "brIf 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: brbr/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 somewherebr" & _ " anyway, so that you won't be inconvenienced if some emergency prevents him frombr" & _ " returning your call at the expected time.]brbr/BLOCKQUOTE" & vbCrLf & vbCrLf & _ " Message: /HTML" With itmMail 'Set body format to HTML .BodyFormat = olFormatHTML .HTMLBody = sFormat '"HTMLH2The body of this message will appear in HTML./H2BODYType the message text here. /BODY/HTML" .Display End With itmMail.Subject = "Tcf: " & sCallersName & " " & CStr(Now) & " Re Case: " & sCaseName itmMail.To = " ' '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 ' -- MarceepooNu |
Ads |
#2
|
|||
|
|||
![]() 1. You shouldn't create a new Application object for Outlook. So, remove the CreateObject line. For being able to still use the appOL variable, write instead: Set appOL=Application 2. Calling frmTelMsgInput01.Show loads the form automatically. So, in the Form_Initialize, don't load it again, and don't call its Show method again. 3. The textboxes are known in the form, there's no need to use another variable for that. So, this is all you should have in the Click event: Private Sub btnCreateEmail4TelMsg_Click() sCallersName = txCallersName.text sCaseName = txCaseName.text Call ThisOutlookSession.TelMsg01Part02(sCallersName, sCaseName) End Sub -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Mon, 6 Oct 2008 09:56:01 -0700 schrieb 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 '"HTMLH2The body of this message will appear in HTML./H2BODYType 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) & " " & _ " strongCaller's Full Name:/strong " & sCallersName & _ " Re strongCase:/strong " & sCaseName & _ "br" & vbCrLf & _ vbCrLf & _ "brIf the caller is listed in ContactsForOfc, THEN: CLICK: 'Options', 'Contacts, " & _ " 'Folders', 'All Public Folders', 'Contacts4Ofc', and THEN SELECT the contact. (Whew!!)br" & _ vbCrLf & _ "brIf 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: brbr/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 somewherebr" & _ " anyway, so that you won't be inconvenienced if some emergency prevents him frombr" & _ " returning your call at the expected time.]brbr/BLOCKQUOTE" & vbCrLf & vbCrLf & _ " Message: /HTML" With itmMail 'Set body format to HTML .BodyFormat = olFormatHTML .HTMLBody = sFormat '"HTMLH2The body of this message will appear in HTML./H2BODYType the message text here. /BODY/HTML" .Display End With itmMail.Subject = "Tcf: " & sCallersName & " " & CStr(Now) & " Re Case: " & sCaseName itmMail.To = " ' '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 ' |
#3
|
|||
|
|||
![]()
It occurred to me that I should mention that I am not using Access; so I
don't understand why I'm getting the error message refers to Access. -- MarceepooNu "MarceepooNu" wrote: 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 '"HTMLH2The body of this message will appear in HTML./H2BODYType 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) & " " & _ " strongCaller's Full Name:/strong " & sCallersName & _ " Re strongCase:/strong " & sCaseName & _ "br" & vbCrLf & _ vbCrLf & _ "brIf the caller is listed in ContactsForOfc, THEN: CLICK: 'Options', 'Contacts, " & _ " 'Folders', 'All Public Folders', 'Contacts4Ofc', and THEN SELECT the contact. (Whew!!)br" & _ vbCrLf & _ "brIf 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: brbr/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 somewherebr" & _ " anyway, so that you won't be inconvenienced if some emergency prevents him frombr" & _ " returning your call at the expected time.]brbr/BLOCKQUOTE" & vbCrLf & vbCrLf & _ " Message: /HTML" With itmMail 'Set body format to HTML .BodyFormat = olFormatHTML .HTMLBody = sFormat '"HTMLH2The body of this message will appear in HTML./H2BODYType the message text here. /BODY/HTML" .Display End With itmMail.Subject = "Tcf: " & sCallersName & " " & CStr(Now) & " Re Case: " & sCaseName itmMail.To = " ' '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 ' -- MarceepooNu |
#4
|
|||
|
|||
![]() Have you tried my suggestions? -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Mon, 6 Oct 2008 15:18:16 -0700 schrieb MarceepooNu: It occurred to me that I should mention that I am not using Access; so I don't understand why I'm getting the error message refers to Access. |
#5
|
|||
|
|||
![]()
Dear Michael:
1. Thank you. Very helpful. (I didn't see or get a notice yesterday about your posting, but I got this one. Thank you.) 2. New error message: "Run-time error '91':" "Object variable or With block variable not set" When i click on debug, this line is highlighted: Call ThisOutlookSession.TelMsg01Part02(sCallersName, sCaseName) I bet you'll gimme a fix; could I impose on you (if it's easy and doesn't take much of your time) to also tell me where I could learn about the errors I've made, so that I'd know more and do better in the future? Thank you again for your help. It is very much appreciated. Marc -- MarceepooNu "Michael Bauer [MVP - Outlook]" wrote: Have you tried my suggestions? -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Mon, 6 Oct 2008 15:18:16 -0700 schrieb MarceepooNu: It occurred to me that I should mention that I am not using Access; so I don't understand why I'm getting the error message refers to Access. |
#6
|
|||
|
|||
![]() Have you declared anywhere a variable called "ThisOutlookSession"? You may learn by reading books, and a lot of excersises. For example, look for these books: - Absolute Beginner´s Guide to Microsoft Office Outlook 2003, by Ken Slovak - Microsoft Outlook Programming, by Sue Mosher -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Tue, 7 Oct 2008 11:33:01 -0700 schrieb MarceepooNu: Dear Michael: 1. Thank you. Very helpful. (I didn't see or get a notice yesterday about your posting, but I got this one. Thank you.) 2. New error message: "Run-time error '91':" "Object variable or With block variable not set" When i click on debug, this line is highlighted: Call ThisOutlookSession.TelMsg01Part02(sCallersName, sCaseName) I bet you'll gimme a fix; could I impose on you (if it's easy and doesn't take much of your time) to also tell me where I could learn about the errors I've made, so that I'd know more and do better in the future? Thank you again for your help. It is very much appreciated. Marc |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
with outlook 2007 errror "Not Implemented | sk | Outlook - General Queries | 3 | June 21st 07 02:27 PM |
UserForm Listbox with Access Database Table data | RobLo | Outlook - Using Forms | 4 | March 9th 07 04:47 PM |
[FIND MESSAGE] fails to find messages for 2007 | Arvin Rex | Outlook Express | 4 | February 6th 07 09:11 PM |
find an Outlook Web Access Tutorial? | Fishman4 | Outlook - General Queries | 1 | April 27th 06 04:09 PM |
Why can't I find contacts in Outlook Web Access? | Kermit | Outlook - Using Contacts | 7 | April 11th 06 04:56 PM |