Can't export a report to word

  • Thread starter José António Silva
  • Start date
J

José António Silva

Having distributed an access application with the Access 2007 run time, I
notice now that the button “Export to Word†is disabled. However, in my
computer, where I have the full Access version this button is available. Why
is this happening? Is something missing in client machines? This also happens
in a machine with word 2007 installed (i.e., standard office).
Thanks,
José António Silva
 
R

ryguy7272

This is code that I use to export to Word:
Sub PatientForm()

Dim appWord As Word.Application
Dim doc As Word.Document
Dim objWord As Object

On Error Resume Next
err.Clear

Set appWord = GetObject(, "Word.Application")
Set objWord = CreateObject("Word.Application")

If err.Number <> 0 Then

objWord.Documents.Open CurrentProject.Path & "\test.doc"
objWord.Visible = True

End If
'Set doc = appWord.Documents.Open("C:\PatientForm.doc", , True)
Set doc = appWord.Documents.Open(CurrentProject.Path &
"\MontefioreRADON.doc", , True)
With doc


..FormFields("Back").Result = [Forms]![Patient]![Back]
..FormFields("Neck").Result = [Forms]![Patient]![Neck]
..FormFields("Head").Result = [Forms]![Patient]![Head]
..FormFields("Arms").Result = [Forms]![Patient]![Arms]
..FormFields("Legs").Result = [Forms]![Patient]![Legs]
..FormFields("ReversedTable").Result = [Forms]![Patient]![ReversedTable]
..FormFields("Other").Result = [Forms]![Patient]![Other]

' If .FormFields("Text1").Result <> "" Then _
' vRecordSet("Company Name") = .FormFields("Text1").Result

..Visible = True
..Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox err.Number & ": " & err.Description

End Sub

Finally, u8ndet Tools > References > Make sure the appropriate Microsoft
Word xxx Object Library is checked.

Finally, why not use a Report. This is similar, but different, from a Word
document. Quite different actually, but when you print hard copies, an
Access Report is completely indistinguishable from a Word Document.

HTH,
Ryan--
 
J

José António Silva

I’m not sure if this answers my question. I’m just wondering why the “export
to word†button isn’t available at run-time. I’m not looking for a solution
that depends of every report I would create. I’m looking for a unique and
general way to export every report to word. Now, I’m just about to believe
that I can create a new ribbon button associated with a function with the
following code:
DoCmd.OutputTo acOutputReport, Application.CurrentObjectName, acFormatRTF
But I still not see the reason why the “equivalent†and original access
button (in the print preview ribbon) is disabled, when it is supposed to do
exactly the same thing I’m trying to do with my “new button†and my “new
functionâ€.
José António Silva

ryguy7272 said:
This is code that I use to export to Word:
Sub PatientForm()

Dim appWord As Word.Application
Dim doc As Word.Document
Dim objWord As Object

On Error Resume Next
err.Clear

Set appWord = GetObject(, "Word.Application")
Set objWord = CreateObject("Word.Application")

If err.Number <> 0 Then

objWord.Documents.Open CurrentProject.Path & "\test.doc"
objWord.Visible = True

End If
'Set doc = appWord.Documents.Open("C:\PatientForm.doc", , True)
Set doc = appWord.Documents.Open(CurrentProject.Path &
"\MontefioreRADON.doc", , True)
With doc


.FormFields("Back").Result = [Forms]![Patient]![Back]
.FormFields("Neck").Result = [Forms]![Patient]![Neck]
.FormFields("Head").Result = [Forms]![Patient]![Head]
.FormFields("Arms").Result = [Forms]![Patient]![Arms]
.FormFields("Legs").Result = [Forms]![Patient]![Legs]
.FormFields("ReversedTable").Result = [Forms]![Patient]![ReversedTable]
.FormFields("Other").Result = [Forms]![Patient]![Other]

' If .FormFields("Text1").Result <> "" Then _
' vRecordSet("Company Name") = .FormFields("Text1").Result

.Visible = True
.Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox err.Number & ": " & err.Description

End Sub

Finally, u8ndet Tools > References > Make sure the appropriate Microsoft
Word xxx Object Library is checked.

Finally, why not use a Report. This is similar, but different, from a Word
document. Quite different actually, but when you print hard copies, an
Access Report is completely indistinguishable from a Word Document.

HTH,
Ryan--



--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


José António Silva said:
Having distributed an access application with the Access 2007 run time, I
notice now that the button “Export to Word†is disabled. However, in my
computer, where I have the full Access version this button is available. Why
is this happening? Is something missing in client machines? This also happens
in a machine with word 2007 installed (i.e., standard office).
Thanks,
José António Silva
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top