I am struggling with automation with office XP.
I have an Access database where every time a user communicates with a customer, it is logged with the date and time. I am trying to create a facility where the user can select from a list of about 5 word templates to create a letter to a customer and embed that letter in a bound object frame. When the letter is created, the appropriate address information should be put into the word document. I have been able to accomplish that using this code:
Dim objWord As Word.Application
Set objWord = New Word.Application
objWord.Visible = True
objWord.Documents.Add Application.CurrentProject.Path _
& "\SalesLetter.dot"
fname = "FullName from database"
Add = "address from database"
sal = "salutation from database"
With objWord.ActiveDocument.Bookmarks
.Item("FullName").Range.Text = fname
.Item("FullAddress").Range.Text = Add
.Item("Salutation").Range.Text = sal
End With
This creates a document and inserts the appropriate data.
I have also been able to figure out how to create an embedded word document:
With Me!Obj
.Enabled = True
.Locked = False
' Specify what kind of object can appear in the field.
.OLETypeAllowed = acOLEEmbedded
' Class statement for Word document.
.Class = "Word.Document"
' Specify the file to be embedded.
' Type the correct path name.
.SourceDoc = Application.CurrentProject.Path & "\SalesLetter.doc"
' Create the embedded object.
.Action = acOLECreateEmbed
End With
But in creating this document, I haven’t been able to determine how refer to the document to execute the code to add address information.
I can see two approaches:
1. Figure out how to add the document I created using automation in the first code snippet to a bound object frame.
2. Figure out how to refer to the document I have created in the bound object frame using automation
Does anyone have any suggestions or alternative approaches?
I have an Access database where every time a user communicates with a customer, it is logged with the date and time. I am trying to create a facility where the user can select from a list of about 5 word templates to create a letter to a customer and embed that letter in a bound object frame. When the letter is created, the appropriate address information should be put into the word document. I have been able to accomplish that using this code:
Dim objWord As Word.Application
Set objWord = New Word.Application
objWord.Visible = True
objWord.Documents.Add Application.CurrentProject.Path _
& "\SalesLetter.dot"
fname = "FullName from database"
Add = "address from database"
sal = "salutation from database"
With objWord.ActiveDocument.Bookmarks
.Item("FullName").Range.Text = fname
.Item("FullAddress").Range.Text = Add
.Item("Salutation").Range.Text = sal
End With
This creates a document and inserts the appropriate data.
I have also been able to figure out how to create an embedded word document:
With Me!Obj
.Enabled = True
.Locked = False
' Specify what kind of object can appear in the field.
.OLETypeAllowed = acOLEEmbedded
' Class statement for Word document.
.Class = "Word.Document"
' Specify the file to be embedded.
' Type the correct path name.
.SourceDoc = Application.CurrentProject.Path & "\SalesLetter.doc"
' Create the embedded object.
.Action = acOLECreateEmbed
End With
But in creating this document, I haven’t been able to determine how refer to the document to execute the code to add address information.
I can see two approaches:
1. Figure out how to add the document I created using automation in the first code snippet to a bound object frame.
2. Figure out how to refer to the document I have created in the bound object frame using automation
Does anyone have any suggestions or alternative approaches?