none
Add two different (Report View and Print Preview View) contextuals (popups) command bar for a report? RRS feed

  • Question

  • Hi,

    I need to create a custom right click contextual menu for a report.

    I know how to create and link it to the report.

    The problem is that, as the built-in, should be different if the report is in Report View or in Print Preview View.

    How can I achieve this?

    Thanks, Lauro

    Wednesday, August 26, 2015 9:36 PM

Answers

  • Hi Edward & DB guy,

    thanks to both of you. I'm going to try two solutions, both based on the workaround proposed by Edward in my other thread.

    The function "getView()" set in the "hidden" Text Box Control source [“=getView()”]

    1. can set differerent commandbar; If view = 5 Then  Me.ShortcutMenuBar = "cmdPrintRClick" Else  Me.ShortcutMenuBar = "cmdReportRClick"
    2. call again the function used Report on Load to set the values if view is changed.

    Lauro

    Wednesday, September 2, 2015 2:27 PM

All replies

  • Hi Lauro,

    Are you using macros or VBA to create the shortcut menus?

    Wednesday, August 26, 2015 10:26 PM
  • VBA

    Thanks, Lauro

    Wednesday, August 26, 2015 10:55 PM
  • Hi Lauro2,

    >> The problem is that, as the built-in, should be different if the report is in Report View or in Print Preview View.

    Do you mean that you want to know whether the custom right click custom menu are different if the report is Report view or Print view? In my option, if the controls in your custom menu are built-in, the behavior of them are the same as the built-in. In other words, if the built-in controls are different in Report view and Print Preview view, your custom menu are different. If the event of the controls in your custom menu are defined by yourself, I think they are the same in Report View and Print Preview view.

    So, for your requirement to achieve the same function in Report View and Print Preview view, I suggest you use your custom controls with custom actions.

    For custom action for a control, here is a simple demo:

    Sub CreateSimpleShortcutMenu()
        Dim cmbShortcutMenu As Office.CommandBar
        Dim cmbControl As Office.CommandBarControl
    
        ' Create a shortcut menu named "SimpleShortcutMenu.
        Set cmbShortcutMenu = CommandBars.Add("SimpleShortcutMenu", msoBarPopup, False, True)
    
        ' Add the Remove Filter/Sort command.
        Set cmbControl = cmbShortcutMenu.Controls.Add(Type:=msoControlButton, Id:=605)
        cmbControl.OnAction = "hello" ‘ custom the click event
        cmbControl.Caption = "Test1"
    
        Set cmbShortcutMenu = Nothing
    
    End Sub
    Sub hello()
    MsgBox "hello word"
    End Sub

    For more information about this, you could refer the link below:

    # CommandBarButton.OnAction Property (Office)
    https://msdn.microsoft.com/en-us/library/office/ff864132.aspx

    Best Regards,

    Edward

                       

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, August 28, 2015 9:04 AM
  • VBA

    Thanks, Lauro


    In that case, try checking the CurrentView property.
    Friday, August 28, 2015 2:49 PM
  • Thanks for the interest.

    What I'm trying to do is this:

    If my report CurrentView is 5 = Print Preview then show a set of CommandBarControls, if is 6 =Report view show another set.

    Some of the controls are built-in others are custom.

    [My problem arise because I'm not able to repurpose the built in controls to change from Print Preview to Report View and viceversa. I need to relood the report at each change.]


    Friday, August 28, 2015 5:32 PM
  • Hi. So, have you tried checking the CurrentView property, say using the Current event, and then assigning the proper shortcut based on the value of the property? I can't do any testing because I don't have any custom shortcuts, so I am not sure if that will work or not. I was hoping it should. Just my 2 cents...
    Friday, August 28, 2015 5:37 PM
  • hi,

    the problem is the same discussed in my other thread:

    The current Event is not fired at Current Event.

    I can't succeed in finding event that is fired when going from PrintPreview View to report View.

    Lauro

    Saturday, August 29, 2015 8:29 AM
  • Hi Lauro. Again, I don't have any shortcut menu to use for testing. But if assigning a shortcut menu to a report using VBA doesn't require it to be opened in design view, then according to your other thread, you were able to call a function to determine the current view by using an unbound textbox on the report. I would suggest try adding code to your function to assign the appropriate context menu based on the result of the CurrentView property. Hope that helps...
    Saturday, August 29, 2015 2:32 PM
  • Hi Lauro,

    Have you tried my suggestion in my first reply? As my test, it will work both in PrintPreview and Report View in the menu of right click. If you have any issues about this, please feel free to let me know.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, September 2, 2015 11:55 AM
  • Hi Edward & DB guy,

    thanks to both of you. I'm going to try two solutions, both based on the workaround proposed by Edward in my other thread.

    The function "getView()" set in the "hidden" Text Box Control source [“=getView()”]

    1. can set differerent commandbar; If view = 5 Then  Me.ShortcutMenuBar = "cmdPrintRClick" Else  Me.ShortcutMenuBar = "cmdReportRClick"
    2. call again the function used Report on Load to set the values if view is changed.

    Lauro

    Wednesday, September 2, 2015 2:27 PM
  • Sounds like a good plan. Let us know how it goes. Good luck!
    Wednesday, September 2, 2015 2:51 PM
  • This video may help.

    https://www.youtube.com/watch?v=G0OetcYcbM8


    If this post answered or helped you find the answer to your question, please mark it as such for other Forum users knowledge.

    Thursday, September 3, 2015 3:44 PM