Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use ribbon button to launch a web page

Status
Not open for further replies.

gnosis13

Programmer
Jul 13, 2001
263
US
We are gradually moving our users from older MS Access databases to SharePoint. So at present some of them are using both Access 2007 and SharePoint when they worked previously from just Access. I have decided to implement a custom ribbon so they can just click a button and not have to worry about where the system resides and get them used to the ribbon for when we move to SP2010.

The method that seems to work best is to create a simple macro that launches the form then put a button on the ribbon to launch the macro. So long as I am just launching Access-based stuff within the database it works great. Of course I wouldn't be posting here if I was going to leave it simple like that.

I want to add buttons to the ribbon that also launch web pages on our SharePoint site. This would be easy if I could get a macro to open a web site but I can't seem to get that to work. I can get some simple code to open a web page but then the ribbon doesn't seem to be able to see the code. Gah!

This just has to be simple. Suggestions?
 
Try using the onAction method to call a function (or a sub) that launches your web page.

onAction="=YourFunction(arg1,arg2...)"

or a sub

onAction="YourSub()"

Note that if your callback calls a sub, then it is expecting specific parameters.
 
Thanks for the response Fancy.

I have tried your suggestion but the XML produces an error as it cannot "see" the function. It may be simple syntax issue. For example I might have a public sub OpenWebSite() nested inside a code module named MyMods. OnAction cannot see OpenWebSite(). However if I have a macro called OpenWebSite it executes it (unfortunately not opening a web page). It's possible that I am not properly directing the XML to my code but it doesn't seem to like anything like MyMods.OpenWebSite() or MyModes!OpenWebSite() etc.
 
Note the equal sign for calling a function:
onAction="=YourFunction([arg1],[arg2],...)"

If your callback calls a sub, then you will need to determine the arguments for the ribbon object.
 
Thanks Fancy

This has been an opportunity for me to learn a bit. I actually cheated a little just to get it working. I now have a button on the ribbon that fires a macro:

<button id="open_hold_ticket" label="New Hold Tickets" imageMso="ImportSharePointList" onAction="open_new_hold_ticket"/>

...and then the macro calls the function:

Public Function open_new_hold_ticket()
Application.FollowHyperlink "End Function

Yes, the function and the macro have the same name. For some reason the button will fire the macro but I get a "not part of this collection..." error if I rename the macro which tells me that the button cannot see the function. Anyway, this is working for now so with some code cleanup I might leave it for the next update. I am definitely going to have to spend some time on the old "Fluent UI".
 
I'm glad you got it working...but your syntax must be wrong because I just tested it and it worked for me. You must place an equal sign in front of the name of the function with a pair of parenthesis at the end.

In your case, the Public Function is open_new_hold_ticket. Therefore the onAction method should look like this:

onAction="=open_new_hold_ticket()"

I haven't worked with sharepoint yet, but I'm assuming you have an Access form with a specific ribbon assigned to it. If so, what I said should work.
 
Sure enough I went back and changed the onAction as you suggested and it worked like a champ! I had tried that before but now I am thinking that I forgot to close and reopen the db after modifying the ribbon XML. I have also learned not to edit the XML inside the table but to copy it in and out of notepad. for some reason weird random characters can pop in there if you edit the text in the table.

Thanks a bunch for the help....as soon as I figure out how to plug in some stars your certainly earned them :)
 
Note that there is a free version of Notepad called XMLNotepad that can be downloaded free. I only worked with it once and it seemed ok. But I have Visual Studio installed and it's better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top