There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox freezes freezing hard drive hardware hijackthis internet internet explorer ipod itunes lan laptop malware motherboard mouse network networking outlook 2007 power printer problem ram router screen slow sound trojan upgrade usb virus vista vista 32-bit windows windows xp winxp wireless
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Stumped - trying to created message box w/outlook 2002 template


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
Favora's Avatar
Junior Member with 1 posts.
 
Join Date: Dec 2004
Experience: Beginner
07-Dec-2004, 11:41 AM #1
Unhappy Stumped - trying to created message box w/outlook 2002 template
I have been spending several hours on project - and have 1 part left which I just can't figure out.
I have designed a new form in outlook 2002. Most of the fields are user-defined drop downs and checkboxes and we have been able to write vba script to push the information into a Word template. My problem is trying to create a "message box" at the end of the form, where the user can type in their summary - and then have that print out to the word template. In the outlook form - we have dragged the "message" field from the Field chooser box and placed in our the form. On the corresponding word document, we have inserted a bookmark and used the command {SET boomark: Message}.
Within the vba script we have included the line :
objDoc.Bookmarks("Message").Range.Insert AfterItem Body. That is the sentence verbatim.
With this combination, I keep getting an error that the ObjDoc is not defined.
I've tried making changes for several hours, but have not been able to figure out what to do. I am taking the liberty of including the entire code -- hopefully someone can help me get this last piece working. It is the 8th bookmark located towards the end. ANY HELP GREATLY APPRECIATED!!!
Sub cmdPrint_Click()
Dim oWordApp
Dim oWordDoc
Dim bolPrintBackground
Dim objProp

Set oWordApp=CreateObject ("Word.Application")
If oWordApp Is Nothing Then
MsgBox "Couldn't start Word."
Exit Sub
End If

'Open a new document
Set oDoc = oWordApp.Documents.Add ("O:\Public\LegalRegulatory\ReferenceMaterials\MyForm77.dot")

'Set the first bookmark to the Market name
Set objProp=Item.UserProperties("A. Market")

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text1"). Result = objProp.Value
End If
End If

'Set the second bookmark to Manager
Set objProp=Item.UserProperties("B. Regulatory Manager")

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text2"). Result = objProp.Value
End If
End If

'Set the third bookmark to Subject
oDoc.FormFields("Text16"). Result = CStr(Item.Subject)

'Get my value via my control.Value
MyValue= Item.UserProperties("G. Benefits").Value
If MyValue = True Then
MyValue = "*Benefits"
Else
MyValue = "***"
End If

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text3"). Result = MyValue
End If

'Get my value via my control.Value
MyValue= Item.UserProperties("H. Claims").Value
If MyValue = True Then
MyValue = "*Claims"
Else
MyValue = "***"
End If

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text4"). Result = MyValue
End If
End If

'Get my value via my control.Value
MyValue= Item.UserProperties("I. Complaints/Appeals").Value
If MyValue = True Then
MyValue = "*Complaints/Appeals"
Else
MyValue = "***"
End If

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text5"). Result = MyValue
End If
End If

'Get my value via my control.Value
MyValue= Item.UserProperties("J. Eligibility").Value
If MyValue = True Then
MyValue = "*Eligibility"
Else
MyValue = "***"
End If

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text6"). Result = MyValue
End If
End If

'Get my value via my control.Value
MyValue= Item.UserProperties("K. Fees/Rates").Value
If MyValue = True Then
MyValue = "*Fees/Rates"
Else
MyValue = "***"
End If

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text7"). Result = MyValue
End If
End If

'Get my value via my control.Value
MyValue= Item.UserProperties("L. Fee For Service Changes").Value
If MyValue = True Then
MyValue = "*Fee For Service Changes"
Else
MyValue = "***"
End If

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text8"). Result = MyValue
End If
End If

'Get my value via my control.Value
MyValue= Item.UserProperties("M. Other").Value
If MyValue = True Then
MyValue = "*Other"
Else
MyValue = "***"
End If

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text9"). Result = MyValue
End If
End If

'Get my value via my control.Value
MyValue= Item.UserProperties("N. Reporting").Value
If MyValue = True Then
MyValue = "*Reporting"
Else
MyValue = "***"
End If

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text10"). Result = MyValue
End If
End If

'Set the fourth bookmark to the Document Status
Set objProp=Item.UserProperties("C. Document Status")

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text11"). Result = objProp.Value
End If
End If

'Set the fifth bookmark to the Effective Date
Set objProp=Item.UserProperties("D. Effective Date")

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text12"). Result = objProp.Value
End If
End If

'Set the sixth bookmark to the Action Required
Set objProp=Item.UserProperties("E. Action Required")

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text13"). Result = objProp.Value
End If
End If

'Set the seventh bookmark to the Response Needed by
Set objProp=Item.UserProperties("F. Response Needed by")

If not objProp Is Nothing Then
If objProp.Type <> olKeywords Then
oDoc.FormFields("Text14"). Result = objProp.Value
End If
End If

'Set the 8th bookmark to the Message
Set objDoc.Bookmarks =("Message") Range. InsertAfter Item.Body


'Get the current Word setting for background printing
bolPrintBackground = oWordApp.Options.PrintBackground

'Turn background printing off
oWordApp.Options.PrintBackground = False

'Print the Word document
oDoc.PrintOut

'Restore previous setting
oWordApp.Options.PrintBackground = bolPrintBackground

'Close and don't save changes to the document
Const wdDoNotSaveChanges = 0
oDoc.Close wdDoNotSaveChanges

'Close the Word instance
oWordApp.Quit

'Clean up
Set oPS = Nothing
Set oDoc = Nothing
Set oWordApp = Nothing
End If
End Sub
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:44 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.