Combobox data from Outlook to Word

G

Guest

From a command button on an Outlook custom form, I would like to send a
combobox value to a Word template. My combobox field name "type" has three
potential values: injury, illness or other. This is my first attempt at VBA,
and so far I've cobbled together the following script for 3 text and 1
checkbox fields, but I can't work out how to do it for my combobox. Any
advice is greatly appreciated.

Sub cmdPrint_Click()
Dim oWordApp
Dim oWordDoc
Dim bolPrintBackground

Set oDoc = oWordApp.Documents.Add("C:\Safety.dot")

Issue = Item.UserProperties.Find("Issue")
oDoc.FormFields("Text1").Result = Issue

Cause = Item.UserProperties.Find("Cause")
oDoc.FormFields("Text2").Result = Cause

OSHANumber = Item.UserProperties.Find("OSHANumber")
oDoc.FormFields("Text3").Result = OSHANumber

Closed = Item.UserProperties.Find("Closed")
If Closed = true then
oDoc.FormFields("Check1").Checkbox.Value = True
End if

bolPrintBackground = oWordApp.Options.PrintBackground

oWordApp.Options.PrintBackground = False

oDoc.PrintOut

oWordApp.Options.PrintBackground = bolPrintBackground

Const wdDoNotSaveChanges = 0
oDoc.Close wdDoNotSaveChanges

oWordApp.Quit

Set oDoc = Nothing
Set oWordApp = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top