View Full Version : Combo box -> WORD


waynerad
09-09-2001, 05:52 PM
G'day!
My question is that i have a form and combo box on the form that lists available types of letters(in WORD). What i would like to do is have the WORD open the letter that is highlighted in the combo box. Is this possible?? If you van help or need more info just email me! Any help is greatly appreciated. W.

DJN
09-11-2001, 01:09 AM
Put the following code behind a command button.
Private Sub cmdYour CommandButton_Click()
Dim objWord As Object
Dim strFile As String
strFile = Me![cboYourComboBoxName]
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Documents.Open (strFile)
End Sub

Randomblink
09-11-2001, 05:39 AM
DJN...
So what you are saying is...
I can open Word from Access and fill in fields on it like I do with reports in Access...?
In your example below, where would you put the file name of the Word Template/Document that you wanted to include...?
And what if you wanted to open a word Document and Append several fields to the end of it...? Is that also possible...?
Curiouser and curiouser...
Danka Shane...

waynerad
09-13-2001, 03:03 AM
G'day, I have tried the code that DJN supplied and it allmost works. The problem that i'm having is that stFile does not seem to know where to look for the word document. I have tried addding the file location in the code, changing the file location in (and out) of the db but i still get a error '5174'. Any idesa??

DJN
09-13-2001, 06:26 AM
Hi Wayne,
I hold the document name in a table along with the path to Word. e.g. FolderName
g:\word\rtfFiles\Audit2.rtf. May seem a bit clunky but it works for me.