How to hide built in ribbons (1 Viewer)

speakers_86

Registered User.
Local time
Today, 01:36
Joined
May 17, 2007
Messages
1,919
I don't know what you mean by popup menu. You mean the right click?
 

speakers_86

Registered User.
Local time
Today, 01:36
Joined
May 17, 2007
Messages
1,919
Run this once from the immediate window:
Code:
Public Sub CopyCutPaste()
    Dim cmbRC  As CommandBar
    Dim cmbButtonCopy As CommandBarButton
    Dim cmbButtonCut As CommandBarButton
    Dim cmbButtonPaste As CommandBarButton
    Dim strBarName As String
    strBarName = "CopyCutPaste"

    On Error Resume Next
    CommandBars(strBarName).Delete
    On Error GoTo 0

    Set cmbRC = CommandBars.Add(strBarName, msoBarPopup, False)


    Set cmbButtonCut = cmbRC.Controls.Add(msoControlButton, 19)
    Set cmbButtonCopy = cmbRC.Controls.Add(msoControlButton, 21)
    Set cmbButtonPaste = cmbRC.Controls.Add(msoControlButton, 22)


    'Cleanup
    Set cmbRC = Nothing

    Set cmbButtonCopy = Nothing
    Set cmbButtonCut = Nothing
    Set cmbButtonPaste = Nothing
End Sub

Call this from your forms load event:
Code:
Public Sub RightClick(frm As Form)
    On Error GoTo err
    Dim ctl    As control

    For Each ctl In frm.Controls
        If ctl.Enabled = True Then
            If TypeOf ctl Is TextBox Then
                ctl.ShortcutMenuBar = "CopyCutPaste"
            End If
            If TypeOf ctl Is ComboBox Then
                ctl.ShortcutMenuBar = "CopyCutPaste"
            End If
        End If
skip:
    Next ctl
    Exit Sub
err:
    If err.Number = 438 Then Resume skip              'object does not support this property
    ReportError err.Number, err.Description, "mdlMSLRoutines | RightClick"
End Sub


There is also an example in the sample databases. I'm almost positive it is from ChrisO. His work can be modified to make dynamic menus.
 

smig

Registered User.
Local time
Today, 08:36
Joined
Nov 25, 2009
Messages
2,209
Thanks,

I do have PopUp menus I made before.
As I thought, these are still in the old style, not the Ribbon style (Not an XML)
 

smig

Registered User.
Local time
Today, 08:36
Joined
Nov 25, 2009
Messages
2,209
can't make the getHelperText to work

I can't make the getHelperText to work :(
Can't find what I'm doing wrong.

here is the BackStage part of the XML
Code:
	<backstage>
		<tab idMso ="TabInfo" visible="false"/>  
		<tab idMso ="TabRecent" visible="false"/>
		<tab idMso ="TabNew" visible="false"/>
		<tab idMso ="TabPrint" visible="false"/>
		<tab idMso ="TabShare" visible="false"/>
		<tab idMso ="TabHelp" visible="false"/>
		<button idMso="SaveObjectAs" visible="false"/>
		<button idMso="FileSaveAsCurrentFileFormat" visible="false"/>
		<button idMso="FileOpen" visible="false"/>
		<button idMso="FileCloseDatabase" visible="false"/>
		<button idMso="ApplicationOptionsDialog" visible="false"/>
		<button idMso="FileExit" visible="false"/>


		<tab id="bsTab1" label="About">
			<firstColumn>
				<taskGroup id="bsTaskGroup1" label=" " />
				<group id="slabBtnInfo" label="Sample Database SampleRibbon 4 for Access 2010" style="warning" >
					<topItems>
						<layoutContainer id="layInfo" layoutChildren="vertical" align="topLeft">
							<imageControl id="imgAbout" image="Ribbon_getImage" />
							<imageControl id="imgAbout2" image="D:\GalOn\ACCDB\icons\clip_icon.bmp" />
							<hyperlink id="hlnk1" label="Google" target="http://www.google.com"/>
							<hyperlink id="hlnk2" label="Send mail" target="mailto:info@accessribbon.com"/>
						</layoutContainer>
					</topItems>
				</group>
				<group id="grpAboutLicense1" label="License gave to:" [COLOR="Red"]gethelperText="Ribbon_GetHelperText1"[/COLOR] style="normal">
					<bottomItems>
						<labelControl id="LblAboutLicense4" getLabel="Ribbon_GetLabel"/>
						<labelControl id="LblAboutLicense5" label=" "/>
					</bottomItems>
				</group>
				<group id="grpAboutLicense2" label="License end date:" [COLOR="red"]gethelperText="Ribbon_GetHelperText2"[/COLOR] style="error">
					<bottomItems>
						<labelControl id="LblAboutLicense6" label=" "/>
						<labelControl id="LblAboutLicense7" label=" "/>
						<labelControl id="LblAboutLicense8" label=" "/>
					</bottomItems>
				</group>
			</firstColumn>
		</tab>


		<button id="BScmdQuit" 
				label="Quit"
				imageMso="OutOfOffice"
				onAction="Ribbon_OnAction"/>
	</backstage>

Here is the getHelperText part code:
Code:
Public Sub Ribbon_GetHelperText1(control As IRibbonControl, helperText)

    On Error GoTo err

        helperText = "GetHelperText1"

    Exit Sub
err:
    Debug.Print err.Description
End Sub

Public Sub Ribbon_GetHelperText2(control As IRibbonControl, helperText)

    On Error GoTo err

        helperText = "GetHelperText2"

    Exit Sub
err:
    Debug.Print err.Description
End Sub

When I load my db the Ribbon crash and I get back the default one.
If I change the getHelperText= to HelperText= the ribbon will work and I will get the text string I put into the XML.
 

speakers_86

Registered User.
Local time
Today, 01:36
Joined
May 17, 2007
Messages
1,919
A couple of things. Firstly, if you are using the xml I posted, I posted a version for 2007. That version does not have a backstage. Make sure you change the xmlns property. Secondly, your xml shows gethelperText. I'm sure it should be getHelperText. Notice the 'H'. I also noticed you did not declare a type for the helperText object. I'm guessing it is a string looking at your code. I hope that helps.
 

smig

Registered User.
Local time
Today, 08:36
Joined
Nov 25, 2009
Messages
2,209
A couple of things. Firstly, if you are using the xml I posted, I posted a version for 2007. That version does not have a backstage. Make sure you change the xmlns property. Secondly, your xml shows gethelperText. I'm sure it should be getHelperText. Notice the 'H'. I also noticed you did not declare a type for the helperText object. I'm guessing it is a string looking at your code. I hope that helps.
WOW, the stupid 'H' made the diffeence :banghead:
Thank you :)

Yes, I know AC2007 does not have BackStage. Already changed the xlmns to 2009/07 for AC2010.

I didn't declare the helperText object. No need to, though it does not use the ByRef as the other get() functions do.

now that it works I can use a single function()
Code:
Public Sub Ribbon_GetHelperText(control As IRibbonControl, helperText)

    On Error GoTo err

Select Case control.ID
    Case "grpAboutLicense1"
        helperText = str_grpAboutLicense1
    Case "grpAboutLicense2"
        helperText = str_grpAboutLicense2
    Case Else
End Select


    Exit Sub
err:
    Debug.Print err.Description
End Sub
 

Users who are viewing this thread

Top Bottom