Control Saved Format Of Merged Documents (1 Viewer)

CharlesWhiteman

Registered User.
Local time
Today, 20:42
Joined
Feb 26, 2007
Messages
421
I'm using the following code which works fine and allows me to create a word document and save it to a generic location. But I also want to simultaneously create/append to a text file in another generic location.

My word document may be a letter which i will send out. The purpose of my text file is to contain data which my document management system will use to suck a copy into it.

I am unsure of the code required to create/append, say 3 fields, in the following format

CompanyName,Date,PathToAutosavedWordDoc

This is the code I am using to generate the work doc. i am thinking that i could modify the same code but only if i can then save the file as a text file and that is what I dont know how to do. (I need it in text format for my EDM system link manager system to read for sucking into the edm system.

Private Sub Command12_Click()
Dim objWord As Object

'Start Microsoft Word.
Set objWord = CreateObject("Word.Application")

With objWord
'Make the application visible.
.Visible = True

'Open the document.
.Documents.Add ("C:\My Documents\CW Database\WordTemplates\ScanexLetter.dot")

'Move to each bookmark and insert text from the form.
.Activedocument.Bookmarks("CompanyName").Select
.Selection.Text = Me.txtLCompanyName
.Activedocument.Bookmarks("Date").Select
.Selection.Text = Me.txtLDate
.Activedocument.Bookmarks("Salutation").Select
.Selection.Text = Me.txtLSalutation

'Print the document in the foreground so Microsoft Word will not close
'until the document finishes printing.
'objWord.ActiveDocument.PrintOut Background:=False
'Dim FName As String
'FName = Me.txtDocName

End With

'Quit Microsoft Word and release the object variable.
'objWord.Quit

objWord.Activedocument.SaveAs (Me.txtDocName)

'objWord.Quit
Set objWord = Nothing
End Sub
 

dcobau

Registered User.
Local time
Tomorrow, 05:42
Joined
Mar 1, 2004
Messages
124
from memory:

1) Create a query that contains the values to be exported,
2) Use the TransferText command to send those values to a text file (you might have to create a temp table for those values).

Dave
 

CharlesWhiteman

Registered User.
Local time
Today, 20:42
Joined
Feb 26, 2007
Messages
421
Thanks, I'm a bit further now off the back of that but not quite there.

I'm using the following OnClick event on a command button

doCmd.transfertext,,"QryLetter","C:\My Documents\linkm.txt", False

now I am getting an error "Query must have at least one destination field"
 

Users who are viewing this thread

Top Bottom