Senin, 02 April 2012

Re: [MS_AccessPros] Run time and right clicking

 

Here's some code I used to build a PowerPoint toolbar and to subsequently add a button. Maybe it can be leveraged. PowerPoint is different fromother MS Office apps i that buttons and their associated macros have to be dynamically created upon opening PowerPoint.

Sub Auto_Open()
Dim oToolbar As CommandBar
Dim oButton As CommandBarButton
Dim MyToolbar As String

' Give the toolbar a name
MyToolbar = "Kewl Tools"

' First, delete the toolbar if it already exists
On Error Resume Next ' so that it doesn't stop on the next line if the toolbar's already there

' Build the command bar
Set oToolbar = CommandBars.Add(Name:=MyToolbar, Position:=msoBarFloating, Temporary:=True)
If Err.Number <> 0 Then ' Probably means the toolbar's already there, so we have nothing to do
Exit Sub
End If

On Error GoTo ErrorHandler

' Now add a button to the new toolbar
Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)

' And set some of the button's properties
With oButton
.DescriptionText = "This is my first button" 'Tooltip text when mouse if placed over button
.Caption = "Button1" 'Text if Text in Icon is chosen
.OnAction = "Button1" 'Runs the Sub Button1() code when clicked
.Style = msoButtonIcon ' Button displays as icon, not text or both
.FaceId = 52 '52 is my favorite pig; chooses icon #52 from the available Office icons
End With

' Repeat the above for as many more buttons as you need to add
' Be sure to change the .OnAction property at least for each new button

' You can set the toolbar position and visibility here if you like
' By default, it'll be visible when created
oToolbar.Top = 150
oToolbar.Left = 150
oToolbar.Visible = True

NormalExit:
Exit Sub ' so it doesn't go on to run the errorhandler code

ErrorHandler:
'Just in case there is an error
MsgBox Err.Number & vbCrLf & Err.Description
Resume NormalExit:
End Sub

Sub Button1()
' This code will run when you click Button 1 added above
' Add a similar subroutine for each additional button you create on the toolbar
' This is just some silly example code. You'd put your real working code here to do whatever
' it is that you want to do
MsgBox "Will you PLEASE stop clicking me? I have a headache already!"
End Sub

I did something similar in MS Project but since I don't have Project installed I can't share its code.

Jeff

----- Original Message -----

The basic recipe (and I'm not being secretive I just can't post the code until/unless I rewrite it) is:

Include a reference to the "Microsoft Office NN.0 Object Library" where NN refers to your Access/Office version e.g. 12 or 14.

Then you will find you can create objects "As" CommandBar et cetera.

A very *very* basic skeleton would be:

Dim MyCBar As CommandBar, MyCBarCtl As CommandBarControl

' Create a new Popup
Set myCBar = CommandBars.ADD(Name:="Sample Toolbar", Position:= msoBarPopup)

Set myCBarCtl = myCBar.Controls.Add(type:=msoControlButton)
With CBarCtl
.style = msoButtonCaption
.caption = "Test"
.TooltipText = Translate("Test TT")
.OnAction = "=MsgBox(""You pressed a toolbar button!"")"
End With

You will need to expand this to either create the Commandbar or set a reference to an existing one and you will have to use some proper functions. Setting the ContextMenu of a form/control to "Sample Toolbar" will popup this simple menu. You will of course want to replace the MsgBox call with your own function or....

You can also add the internal Functions using something like:

myCBar.Controls.Add id:=Application.CommandBars("Filter/Sort").Controls("Microsoft Access Help").id

Which is probably what you are looking to do in general, adding the various sort/Filter options you want/need.

Sorry if this is cryptic, one last tip... I actually created my static popups in Access 2000 using the old standards. They are still there in Access 2000 and can still be activated (or selected as Contextmenu for a form/control) using their old names.

--- In MS_Access_Professionals@yahoogroups.com , "Stuart Luckman" <stuartluckman@...> wrote:
>
> Bill,
>
>
>
> I was wondering if you could do this without using the macros, they end up
> being the only macros in the application.
>
>
>
> Hopefully you can do this just with VBA.
>
>
>
> Cheers,
>
> Stuart
>
> My Signature
>
>
>
>
>
> From: MS_Access_Professionals@yahoogroups.com
> [mailto: MS_Access_Professionals@yahoogroups.com ] On Behalf Of Bill Mosca
> Sent: Saturday, 31 March 2012 1:28 AM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: Re: [MS_AccessPros] Run time and right clicking
>
>
>
>
>
> Stuart -
>
> Ah HA! Macro Name has been replaced with Sub Macro. I guess that makes sense
> seeing how macros are gradually making their way into the VBA World for
> Dummies. Now a macro name is a sub routine.
>
> Thanks for giving me a sample, Stuart. If I get some time I'll poke around
> in my copy of Access 2010 Inside Out to see how to make a real context menu
> without macros called to expose them.
>
> Bill
>
> --- In MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com> , "Stuart Luckman"
> <stuartluckman@> wrote:
> >
> > Liz/Bill,
> >
> >
> >
> > I have uploaded an example which works on my machine.
> >
> > Hope it all works for you.
> >
> >
> >
> > Cheers,
> >
> > Stuart
> >
> >
> >
> >
> >
> >
> >
> > From: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > [mailto: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com> ] On Behalf Of Stuart
> Luckman
> > Sent: Friday, 30 March 2012 10:50 AM
> > To: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > Subject: RE: [MS_AccessPros] Run time and right clicking
> >
> >
> >
> >
> >
> > Hi Bill,
> >
> > I'm using 2007, I've never used 2003.
> >
> > When you have the macro open in design view, click on the design ribbon at
> > the top and in the Show/Hide group their is Show all actions, Macro Names,
> > Conditions, Arguments.
> >
> > There you click on Macro Names.
> >
> > I'm no pro, so I'm not great at explaining . . . I'll try to get an
> example
> > posted.
> >
> > Cheers,
> >
> > Stuart
> >
> > My Signature
> >
> > From: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > [mailto: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com> ] On Behalf Of Bill
> Mosca
> > Sent: Friday, 30 March 2012 10:32 AM
> > To: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > Subject: RE: [MS_AccessPros] Run time and right clicking
> >
> > Hi Stuart
> >
> > I don't see a macro name column and can't find a way to expose it like you
> > could
> > in 2003.
> >
> > Regards,
> >
> > Bill
> >
> > From: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > [mailto: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com> ] On Behalf Of Stuart
> > Luckman
> > Sent: Thursday, March 29, 2012 1:42 PM
> > To: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > Subject: RE: [MS_AccessPros] Run time and right clicking
> >
> > Hi Liz/Bill,
> >
> > I am using Access 2007 but I forgot one part of the step.
> >
> > In the FlitMenuFunc macro add the Macro Name: Filter and Sort
> >
> > Otherwise it looks like you have nothing to click on.
> >
> > Sorry it took so long replying, I'm in Australia so when you guys were
> > chatting I was sleeping.
> >
> > Cheers,
> >
> > Stuart
> >
> > From: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > [mailto: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com> ] On Behalf Of Liz
> > Ravenwood
> > Sent: Friday, 30 March 2012 4:22 AM
> > To: 'MS_Access_Professionals@yahoogroups.com
> <mailto:%27MS_Access_Professionals%40yahoogroups.com>
> > <mailto:%27MS_Access_Professionals%40yahoogroups.com>
> > <mailto:%27MS_Access_Professionals%40yahoogroups.com>
> > <mailto:%27MS_Access_Professionals%40yahoogroups.com> '
> > Subject: RE: [MS_AccessPros] Run time and right clicking
> >
> > Thanks Bill. I appreciate the validity.
> >
> > Liz Ravenwood
> > Database Developer / Programmer
> > Super First Class Products
> > B/E Aerospace
> > O: 1.520.239.4808
> > www.beaerospace.com
> >
> > -----Original Message-----
> > From: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > [mailto: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com> ] On Behalf Of Bill
> Mosca
> > Sent: Thursday, March 29, 2012 10:18 AM
> > To: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > Subject: RE: [MS_AccessPros] Run time and right clicking
> >
> > Liz
> >
> > I followed Stuart's instructions and I get what you get: a blank box.
> Maybe
> > Stuart was working with Access 2003 or earlier and this isn't translating
> in
> > 2007 or 2010.
> >
> > Maybe someone can step in and give us another way.
> >
> > Regards,
> >
> > Bill
> >
> > From: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > [mailto: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com> ] On Behalf Of Liz
> > Ravenwood
> > Sent: Thursday, March 29, 2012 9:31 AM
> > To: 'MS_Access_Professionals@yahoogroups.com
> <mailto:%27MS_Access_Professionals%40yahoogroups.com>
> > <mailto:%27MS_Access_Professionals%40yahoogroups.com>
> > <mailto:%27MS_Access_Professionals%40yahoogroups.com>
> > <mailto:%27MS_Access_Professionals%40yahoogroups.com>
> > <mailto:%27MS_Access_Professionals%40yahoogroups.com> '
> > Subject: RE: [MS_AccessPros] Run time and right clicking
> >
> > Bill. I did this and when I open up the accdr, I don't see any menu nor
> have
> > any
> > response from my right clicking on the form.
> >
> > Liz Ravenwood
> > Database Developer / Programmer
> > Super First Class Products
> > B/E Aerospace
> > O: 1.520.239.4808
> > www.beaerospace.com
> >
> > -----Original Message-----
> > From: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > [mailto: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com> ] On Behalf Of Bill
> Mosca
> > Sent: Thursday, March 29, 2012 9:18 AM
> > To: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > Subject: RE: [MS_AccessPros] Run time and right clicking
> >
> > Liz
> >
> > I'll let Stuart continue with this topic, but I thought I'd interject
> this:
> >
> > Runtime has no menus except the very limited File menu. No context menus.
> > None.
> > Nadda.
> >
> > You have to build all the custom menus, including context (right-click)
> > menus,
> > custom toolbars (or Ribbons if in 2007/2010).
> >
> > To see what your runtime users will see use:
> >
> > 1. If file is MDB - the /runtime switch in a shortcut to open the database
> > as in:
> >
> > "C:\Program Files\Microsoft Office\Office11\msaccess.exe" /runtime
> > "YourDBFullPath"
> >
> > 2. If accdb change file extension to accdr
> >
> > Regards,
> >
> > Bill
> >
> > From: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > [mailto: MS_Access_Professionals@yahoogroups.com
> <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com>
> > <mailto:MS_Access_Professionals%40yahoogroups.com> ] On Behalf Of Liz
> > Ravenwood
> > Sent: Wednesday, March 28, 2012 3:59 PM
> > To: 'MS_Access_Professionals@yahoogroups.com
> <mailto:%27MS_Access_Professionals%40yahoogroups.com>
> > <mailto:%27MS_Access_Professionals%40yahoogroups.com>
> > <mailto:%27MS_Access_Professionals%40yahoogroups.com>
> > <mailto:%27MS_Access_Professionals%40yahoogroups.com>
> > <mailto:%27MS_Access_Professionals%40yahoogroups.com>
> > <mailto:%27MS_Access_Professionals%40yahoogroups.com> '
> > Subject: [MS_AccessPros] Run time and right clicking
> >
> > Greetings pros, I just learned that creating a run time version (accdr)
> > loses
> > right click capability.
> >
> > I searched on line and see that there was some bug that was fixed but not
> in
> > the
> > run time version... is that correct?
> >
> > Does anyone know how to give someone right click access or if they know
> that
> > I'm
> > missing something here?
> >
> > Liz Ravenwood
> > Database Developer / Programmer
> > Super First Class Products
> > B/E Aerospace
> > O: 1.520.239.4808
> > www.beaerospace.com
> >
> > This email (and all attachments) is for the sole use of the intended
> > recipient(s) and may contain privileged and/or proprietary information.
> Any
> > unauthorized review, use, disclosure or distribution is prohibited. If you
> > are
> > not the intended recipient, please contact the sender by reply e-mail and
> > destroy all copies of the original message.
> >
> > [Non-text portions of this message have been removed]
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> > This email (and all attachments) is for the sole use of the intended
> > recipient(s) and may contain privileged and/or proprietary information.
> Any
> > unauthorized review, use, disclosure or distribution is prohibited. If you
> > are
> > not the intended recipient, please contact the sender by reply e-mail and
> > destroy all copies of the original message.
> >
> > [Non-text portions of this message have been removed]
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> > This email (and all attachments) is for the sole use of the intended
> > recipient(s) and may contain privileged and/or proprietary information.
> Any
> > unauthorized review, use, disclosure or distribution is prohibited. If you
> > are not the intended recipient, please contact the sender by reply e-mail
> > and destroy all copies of the original message.
> >
> > [Non-text portions of this message have been removed]
> >
> > [Non-text portions of this message have been removed]
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
>
> [Non-text portions of this message have been removed]
>

--

Jeffrey Park Jones
Excel, Access, Word, Office Expert
Excel and Access, LLC®
Christopher@ExcelAndAccess.Com
http://ExcelAndAccess.Com
Toll Free 877-392-3539
Direct Line 714-262-6893

919-671-9870
5109 Deer Lake Trail
Wake Forest, NC 27587
jpjones23@centurylink.net

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar