PC Review


Reply
Thread Tools Rate Thread

Access runtime ribbon - export to word option missing.

 
 
Louverril
Guest
Posts: n/a
 
      7th Jun 2010
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

 
Reply With Quote
 
 
 
 
Tom van Stiphout
Guest
Posts: n/a
 
      12th Jun 2010
On Mon, 7 Jun 2010 11:06:10 -0700, Louverril
<(E-Mail Removed)> wrote:

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



>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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Ribbon Export Group Jonathan Microsoft Access External Data 1 20th Jun 2009 04:34 AM
Access Ribbon in Runtime BigBass1 Microsoft Access 0 4th Dec 2008 05:10 PM
Access 2007 Runtime export to Microsoft Word JohnB Microsoft Access External Data 6 18th Nov 2008 03:20 PM
disabled ribbon in access 2007 runtime zkmoon Microsoft Access VBA Modules 0 3rd Sep 2008 07:28 PM
Issue with Word export from Access 2003 - missing text Bogdan Microsoft Access External Data 0 10th Jan 2008 06:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:30 PM.