G
Guest
I am trying to get Access to output to word, much like using "write #1,
StringOfImportantText"; however, i have no idea how to accomplish tihs
without using Word Fields. Thank you for your help.
Goals of this exercise:
1) export fields from a query to word
2) apply formatting to certain paragraphs
3) create tables
4) apply formatting to tables, including column width
5) do this with an everchanging query
Public Sub printWord(ByVal qry As DAO.Recordset, _
ByVal progBar As Control, _
ByVal tmpPath As String, _
ByVal runTime As Date, _
Optional ByVal strDivision As String, _
Optional ByVal strTable As String)
Dim appWord As Word.Application
Dim docWord As Word.Document
Dim strDoc As String
strDoc = "wordTemplate.dot"
On Error Resume Next
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then Set appWord = CreateObject("Word.Application"):
Err.Clear
appWord.Visible = True
Set docWord = appWord.Documents.Add(tmpPath & "\" & strDoc)
docWord.SaveAs tmpPath & "\" & qry![nameDivision].Value & " " &
strDate(runTime) & " " & strTime(runTime) & ".doc"
'let MS Access do the typing
'
' Pseudo Code:
' write qry![nameTable].Value
' apply heading1 to qry![nameTable].Value
' insert table (3 colums by 1 row)
' apply tableStyle to table; make column1 2", make column2 1", make
column3, 1"
' write "name", "quantity", "percent" in table row
'
' add row
' write firstname in column1
' write amountsold in column2
' write percent in column3
'
' and so on... from the start to then end of the query.
'
docWord.SaveAs tmpPath & "\" & qry![nameDivision].Value & " " &
strDate(runTime) & " " & strTime(runTime) & ".doc"
appWord.Quit True
End Sub
StringOfImportantText"; however, i have no idea how to accomplish tihs
without using Word Fields. Thank you for your help.
Goals of this exercise:
1) export fields from a query to word
2) apply formatting to certain paragraphs
3) create tables
4) apply formatting to tables, including column width
5) do this with an everchanging query
Public Sub printWord(ByVal qry As DAO.Recordset, _
ByVal progBar As Control, _
ByVal tmpPath As String, _
ByVal runTime As Date, _
Optional ByVal strDivision As String, _
Optional ByVal strTable As String)
Dim appWord As Word.Application
Dim docWord As Word.Document
Dim strDoc As String
strDoc = "wordTemplate.dot"
On Error Resume Next
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then Set appWord = CreateObject("Word.Application"):
Err.Clear
appWord.Visible = True
Set docWord = appWord.Documents.Add(tmpPath & "\" & strDoc)
docWord.SaveAs tmpPath & "\" & qry![nameDivision].Value & " " &
strDate(runTime) & " " & strTime(runTime) & ".doc"
'let MS Access do the typing
'
' Pseudo Code:
' write qry![nameTable].Value
' apply heading1 to qry![nameTable].Value
' insert table (3 colums by 1 row)
' apply tableStyle to table; make column1 2", make column2 1", make
column3, 1"
' write "name", "quantity", "percent" in table row
'
' add row
' write firstname in column1
' write amountsold in column2
' write percent in column3
'
' and so on... from the start to then end of the query.
'
docWord.SaveAs tmpPath & "\" & qry![nameDivision].Value & " " &
strDate(runTime) & " " & strTime(runTime) & ".doc"
appWord.Quit True
End Sub