Unhide RibbonBar

gavinjb

Registered User.
Local time
Today, 12:00
Joined
Mar 23, 2006
Messages
39
Hi,

I am trying to right a function to unhide a ribbon bar when a particular Report iss open, as Ctrl + F1 Hides/Unhides the Ribbon bar my thought was to test for the height of the bar and then unhide if required, the code I have is

Code:
If Application.CommandBars("Ribbon").Height <> 147 Then
SendKeys "^{F1}", True
End If

Only problem is that if you Press Ctrl + F1 in Access it works but when you use SendKeys to do this Help popus up!

Any one with any ideas.

Thanks,



Gavin,
 
gavin,

is the carrot the correct symbol for the ctrl button? the syntax looks right. there should be a minimized property for the ribbon as well. look in VBA help for RIBBON. there's a lot on it
 
Hi Adam,

Thanks, but unfortunately when I search the help there doesn't seem to be anything n minimizing.maximizing the ribbon in vba (I even tried recording a macro in word, to see if I could convert the vba to access, but righ clicking the bar and selecting the minimize records nothing!)

I have checked the help and ^ should be the control key in sendkeys

I did find this code on a forum for using the ribbon in c#

Code:
In ThisAddIn.cs

private static Office.CommandBars cbs = null;

 

        private void ThisAddIn_Startup(object sender, System.EventArgs e)

        {

            this.CustomTaskPanes.Add(new UserControl1(),"test").Visible = true;

            cbs = this.Application.CommandBars;

        }

 

        public static Office.CommandBar returnRibbon()

        {

            foreach (Office.CommandBar cb in cbs)

            {

                if (cb.Name == "Ribbon")

                {

                    return cb;

                }

            }

            return null;

        }

In CustomTaskPane’s UserControl1.cs

private void button1_Click(object sender, EventArgs e)

        {

            int i = ThisAddIn.returnRibbon().Height;

            if (i == 147)

            {

                Globals.ThisAddIn.Application.ActiveWindow.ToggleRibbon();

            }

            else

            {

 

            }

        }

but it seems that the ToggleRibbon isn't available in Access


Gavin,
 
I have found what the problem is with sendkeys, but not sure what the sollution is though.

if I press Ctrl + F1 in access it hides/unhides the ribbon, but if I press ctrl+F1 in the vba editor it shows the help, so not sure if anyone can tell me how to get the sendkeys "^{F1}" to affect access.
 

Users who are viewing this thread

Back
Top Bottom