fat controller
Slightly round the bend..
- Local time
- Today, 15:45
- Joined
- Apr 14, 2011
- Messages
- 758
I have a database that when deployed will be used mainly via the Access Runtime environment, and therefore the features to export reports to Excel, Word etc will not be available.
In the past, I have used a custom shortcut menu, code as follows:
So, I thought I had nothing more to do than pinch that code, and use it in the new database...... initially, I got a runtime error (object not defined) with the line Dim CB as CommandBar hightlighted.
I added in Microsoft Office 15 Objects as a reference, and thereafter the code compiled fine - however, it does not appear to work.
I have stepped into the code, and it runs through as though it is doing its thing, but when I right click on the report in Preview, I get the 'normal' shortcut menu.
Any ideas?
In the past, I have used a custom shortcut menu, code as follows:
Code:
Dim MenuName As String
Dim CB As CommandBar
Dim CBB As CommandBarButton
MenuName = "vbaShortcutMenu"
On Error Resume Next
Application.CommandBars(MenuName).Delete
On Error GoTo 0
Set CB = Application.CommandBars.Add(MenuName, msoBarPopup, False, False)
Set CBB = CB.Controls.Add(msoControlButton, 19, , , True)
CBB.Caption = "Copy..."
CBB.FaceId = 19
Set CBB = CB.Controls.Add(msoControlButton, 22, , , True)
CBB.Caption = "Paste..."
CBB.FaceId = 1436
Set CBB = CB.Controls.Add(msoControlButton, 11725, , , True)
CBB.Caption = "Export to Word..."
CBB.FaceId = 42
Set CBB = CB.Controls.Add(msoControlButton, 11723, , , True)
CBB.Caption = "Export to Excel…"
CBB.FaceId = 263
Set CBB = CB.Controls.Add(msoControlButton, 12499, , , True)
CBB.Caption = "Save as PDF…"
CBB.FaceId = 3
Set CB = Nothing
Set CBB = Nothing
End Sub
So, I thought I had nothing more to do than pinch that code, and use it in the new database...... initially, I got a runtime error (object not defined) with the line Dim CB as CommandBar hightlighted.
I added in Microsoft Office 15 Objects as a reference, and thereafter the code compiled fine - however, it does not appear to work.
I have stepped into the code, and it runs through as though it is doing its thing, but when I right click on the report in Preview, I get the 'normal' shortcut menu.
Any ideas?