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
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