Hi All,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
I have got a report generate the output in excel is fine, but the user would like to see the output in Ms Word.
I have used the following code to generate the results in Ms Word , the results are fine but the formatting is out.
<o></o>
appAccess.DoCmd.OutputTo acOutputReport, ReportName, OPType, DestinationPath & DestinationName<o></o>
To get the right format(Borders on Table ) I can generate the output on SNP format. But I would like the output only in DOC format so the user can further edit as per their requirement
I would be grateful if you could give any suggestion please.
Many thanks
Regards
Farhan
Trying to use the following VBA code but giving me error UserDefined Type not defined
The following code i'm trying to use on MsAccess-2003
Sub Export_Word()<o></o>
<o></o>
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
I have got a report generate the output in excel is fine, but the user would like to see the output in Ms Word.
I have used the following code to generate the results in Ms Word , the results are fine but the formatting is out.
<o></o>
appAccess.DoCmd.OutputTo acOutputReport, ReportName, OPType, DestinationPath & DestinationName<o></o>
To get the right format(Borders on Table ) I can generate the output on SNP format. But I would like the output only in DOC format so the user can further edit as per their requirement
I would be grateful if you could give any suggestion please.
Many thanks
Regards
Farhan
Trying to use the following VBA code but giving me error UserDefined Type not defined
The following code i'm trying to use on MsAccess-2003
Sub Export_Word()<o></o>
<o></o>
Dim rsdata As New ADODB.Recordset<o></o>
Dim strSql As String<o></o>
<o></o>
strSql = "SELECT * FROM Table1;"<o></o>
rsdata.Open strSql, CurrentProject.Connection<o></o>
<o></o>
Dim oWord As Word.Application<o></o>
Dim oDoc As Word.Document<o></o>
Set oWord = New Word.Application<o></o>
Set oDoc = New Word.Document<o></o>
<o></o>
oDoc.ActiveWindow.Selection.Tables.Add Range:=oDoc.ActiveWindow.Selection.Range, numrows:=1, numcolumns:=3<o></o>
'numcolumns:= has to be customized<o></o>
<o></o>
'Create headers<o></o>
oDoc.Tables(1).Columns(1).Cells(1).Range.Text = "..test1.."<o></o>
oDoc.Tables(1).Columns(2).Cells(1).Range.Text = "..test2.."<o></o>
oDoc.Tables(1).Columns(3).Cells(1).Range.Text = "..test3.."<o></o>
'etc.<o></o>
<o></o>
'Export Data<o></o>
i = 1<o></o>
Do Until rsdata.EOF<o></o>
oDoc.Tables(1).Columns(1).Cells.Add<o></o>
oDoc.Tables(1).Columns(1).Cells(i + 1).Range.Text = rsdata.Fields(0)<o></o>
oDoc.Tables(1).Columns(2).Cells(i + 1).Range.Text = rsdata.Fields(1)<o></o>
oDoc.Tables(1).Columns(3).Cells(i + 1).Range.Text = rsdata.Fields(2)<o></o>
'etc.<o></o>
i = i + 1<o></o>
<o></o>
rsdata.MoveNext<o></o>
<o></o>
Loop<o></o>
<o></o>
oDoc.ActiveWindow.Document.SaveAs ("C:\Export.doc")<o></o>
<o></o>
oDoc.ActiveWindow.Document.Close True<o></o>
oWord.Quit True<o></o>
Set oDoc = Nothing<o></o>
Set oWord = Nothing<o></o>
<o></o>
rsdata.Close<o></o>
Set rsdata = Nothing<o></o>
Last edited: