Bericht exportieren in accde & Access-Runtime
- Details
- Kategorie: Menüleiste / Menüband / Ribbon
- Freitag, 05. Februar 2016 15:56
- Ewald Klumpp
- | Anzahl Zugriffe: 10500

Jeder, der schon einmal eine Datenbank geschrieben hat, die auf accde bzw. mit einer Runtime laufen soll hat sicherlich festgestellt, dass die Export-Funktionen nicht angezeigt werden im Standard-Menüband.
Mit etwas Programmierung kann man das Manko umgehen:
1. muss man in der USysRibbons einen Eintrag für Drucken erstellen. Die RibbonXml lautet wie folgt
- <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
- <ribbon startFromScratch="true">
- <tabs>
- <tab id="MyReport" label="Bericht Drucken/exportieren">
-
-
- <group idMso="GroupPrintPreviewPrintAccess" />
- <group idMso="GroupPageLayoutAccess" />
- <group idMso="GroupZoom" />
-
-
-
- <group id="ListCommands" label="Drucken">
- <button idMso="FilePrintQuick" keytip="q" size="large"/>
- <button idMso="PrintDialogAccess"
- label="Print Dialog"
- keytip="d" size="large"/>
- </group>
-
- <group id="ExportCmds" keytip="e" label="Daten exportieren">
- <button idMso="PublishToPdfOrEdoc" keytip="p" size="large"/>
-
- <button id="ExportExcel" label="Excel"
- imageMso="ExportExcel" size="large"
- onAction="=MyExport('XLS')"/>
-
-
- <button id="ExportWord" label="Word"
- imageMso="ExportWord" size="large"
- onAction="=MyExport('RTF')"/>
-
-
- <button id="ExportTextFile" label="Text"
- imageMso="ExportTextFile" size="large"
- onAction="=MyExport('TXT')"/>
-
-
- <button id="ExportHtml" label="HTML Dokument"
- imageMso="ExportHtmlDocument" size="large"
- onAction="=MyExport('HTML')"/>
-
-
- <button id="CreateEmail" label="als E-Mail senden (PDF)"
- imageMso="FileSendAsAttachment"
- enabled="true" size="large"
- onAction= "=MySend()"/>
- </group>
-
-
-
- <group idMso="GroupZoom"></group>
-
- <group id="Exit" keytip="x" label="Schließen">
- <button idMso="PrintPreviewClose" keytip="c" size="large"/>
- </group>
-
-
- </tab>
- </tabs>
- </ribbon>
- </customUI>
2. Ein Modul erstellen mit folgendem Code:
- Public Function MySend()
- DoCmd.SendObject acSendReport, Screen.ActiveReport.Name, acFormatPDF
- End Function
-
-
-
- Public Function MyExport(strFormat As String)
-
-
- Dim strFileType As String
- Dim strFileFilter As String
- Dim strFileName As String
-
- Select Case strFormat
- Case "RTF" ' word
- strFileType = acFormatRTF
- strFileFilter = "*.rtf"
- Case "XLS" ' excel
- strFileType = acFormatXLS
- strFileFilter = "*.XLS"
- Case "TXT" ' text
- strFileType = acFormatTXT
- strFileFilter = "*.txt"
- Case "HTML"
- strFileType = acFormatHTML
- strFileFilter = "*.html"
- Case "PDF"
- strFileType = acFormatPDF
- strFileFilter = "*.pdf"
- Case Else
- Exit Function
- End Select
-
- strFileName = SaveFileName(strFileType, strFileType, strFileFilter)
-
- If strFileName <> "" Then
- DoCmd.OutputTo acOutputReport, Screen.ActiveReport.Name, strFileType, strFileName
- Application.FollowHyperlink strFileName
- End If
- End Function
-
-
- Public Function SaveFileName(strTitle As String, _
- strFilterText As String, _
- strFilter As String) As String
-
- Dim f As Office.FileDialog
- Dim strF As String
- Dim strExt As String
-
- Set f = Application.FileDialog(msoFileDialogSaveAs)
-
- f.Title = strTitle
- 'f.Filters.Add strFilterText, strFilter ' not supported with save as
-
- If f.Show = True Then
- strF = f.SelectedItems(1)
- strExt = Split(strFilter, "*")(1)
- If InStr(strF, strExt) = 0 Then
- ' user did not type extension
- strF = strF & strExt
- End If
- SaveFileName = strF
- End If
- End Function
3. Den RibbonName im gewünschten Bericht auswählen.
Nun müsste beim öffnen ein Menüband angezeigt werden aus dem man Drucken und Exportieren kann...