Access runtime ribbon - export to word option missing.

L

Louverril

When you create a 2007 runtime application the option on the print preview
ribbon to export the report to word disapears.
I have had to create my own Ribbon code to export data to excel (see below -
this works by the way I am just positing it for info) because that option
also disappears.

Do I have to create an equivalent for word, and how would this look (needs
to cope with older version of word), or is there an easier way?


Thanks, Lou

This is what I did for Excel.




' Export whatever records currently displayed to excel. Uses late binding to
allow for different
' versions of office

On Error GoTo ANEError


'define variables
Dim xlApp As Object
Dim xlWorkbook As Object
Dim objRST As Recordset
'Dim strWorkbook As String
Dim strSheetname As String
Dim xlsheet As Object


'create the excel application object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True

'create a new workbook
'strWorkbook = "NewExport"
Set xlWorkbook = xlApp.Workbooks.Add


'define variables

'create the recordset
Set objRST = Screen.ActiveForm.RecordsetClone

'create a sheet name - must be 30 characters or less
strSheetname = "ANE Business System Export"

'copy data from the recordset to the cells


Set xlsheet = xlWorkbook.Sheets(1)
With xlsheet
.Cells.CopyFromRecordset objRST
.Name = strSheetname
End With

'clean up all variables
Set objRST = Nothing
Set xlsheet = Nothing
Set xlWorkbook = Nothing
Set xlApp = Nothing


'Fix to ensure the data can be exported more than once without closing
the form and reopening
'setfocus, requery, refresh do not work.
If Screen.ActiveForm.FilterOn = False Then
Screen.ActiveForm.Filter = "True"
Screen.ActiveForm.FilterOn = True
Screen.ActiveForm.FilterOn = False
'Screen.ActiveForm.Filter = vbNullString
Else
Screen.ActiveForm.FilterOn = False
Screen.ActiveForm.FilterOn = True
End If
 
T

Tom van Stiphout

On Mon, 7 Jun 2010 11:06:10 -0700, Louverril

I'm doing the same thing, but with a lot less code. Here is the ribbon
entry:

<group id="gExport" label="Export" >
<button id ="cmdExportToExcel"
label="Export to Excel"
size="large"
imageMso="ExportExcel"
onAction="cmdExportToExcel_OnAction"/>
</group>

Here is the callback function:
Public Sub cmdExportToExcel_OnAction(ByVal control As IRibbonControl)
RunCommand acCmdExportExcel
End Sub

There is also an acCmdExportRTF for exporting to Word.

-Tom.
Microsoft Access MVP
 

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