C
Chris
I have a need to open a document from within MS Access and then do a replace
on individual items in the doc with text pulled from an Access query.
Where can I start in order to get this to happen?
I am currently using an example module in an old access help file (97) but
it has many thing wrong to begin with.
Private Sub Command2_Click()
Dim WordObj As Object
Dim WordDoc As Document
'Dim WordRng As Range
'Dim WordPar As Paragraph
Set WordObj = CreateObject("Word.Application")
With WordObj
.WindowState = wdWindowStateMaximize
.Documents.Add
Set WordDoc = WordObj.ActiveDocument
Set WordRng = WordDoc.Range
With WordRng
.Font.Bold = True
.Font.Italic = True
.Font.Size = 16
.InsertAfter "Running Word From Access Using Automation"
.InsertParagraphAfter
'Insert a blank paragraph between the two paragraphs
.InsertParagraphAfter
End With
Set WordPar = WordRng.Paragraphs(3)
With WordPar.Range
.Bold = True
.Italic = False
.Font.Size = 12
.InsertAfter "Report Created: "
.Collapse Direction:=wdCollapseEnd
.InsertDateTime DateTimeFormat:="MM-DD-YY HH:MM:SS"
End With
.ActiveDocument.SaveAs "c:\My Documents\autCreateDate.Doc"
.Quit
End With
End Sub
First, there is no declaring a "range" in access. The original says to
declare wordrange as word.range, but that is a big flop in Access' eyes.
Please help !
Thanks!
Chris
chris dottt luksha att sequoyatech dott com
on individual items in the doc with text pulled from an Access query.
Where can I start in order to get this to happen?
I am currently using an example module in an old access help file (97) but
it has many thing wrong to begin with.
Private Sub Command2_Click()
Dim WordObj As Object
Dim WordDoc As Document
'Dim WordRng As Range
'Dim WordPar As Paragraph
Set WordObj = CreateObject("Word.Application")
With WordObj
.WindowState = wdWindowStateMaximize
.Documents.Add
Set WordDoc = WordObj.ActiveDocument
Set WordRng = WordDoc.Range
With WordRng
.Font.Bold = True
.Font.Italic = True
.Font.Size = 16
.InsertAfter "Running Word From Access Using Automation"
.InsertParagraphAfter
'Insert a blank paragraph between the two paragraphs
.InsertParagraphAfter
End With
Set WordPar = WordRng.Paragraphs(3)
With WordPar.Range
.Bold = True
.Italic = False
.Font.Size = 12
.InsertAfter "Report Created: "
.Collapse Direction:=wdCollapseEnd
.InsertDateTime DateTimeFormat:="MM-DD-YY HH:MM:SS"
End With
.ActiveDocument.SaveAs "c:\My Documents\autCreateDate.Doc"
.Quit
End With
End Sub
First, there is no declaring a "range" in access. The original says to
declare wordrange as word.range, but that is a big flop in Access' eyes.
Please help !
Thanks!
Chris
chris dottt luksha att sequoyatech dott com