Home > Mobile >  Activate workbook if it's running otherwise start it
Activate workbook if it's running otherwise start it

Time:07-27

I have a workbook shortcut with a custom icon pinned to the taskbar. The workbook runs most of the day, but is usually behind some other windows. I would like my very non-techie users to be able to click on this icon and have it start the workbook if it's not already open; otherwise give the workbook focus and bring it forward. Now, when they don't realize that it's running and click on the icon, it wants to start another instance of the workbook which confuses them and causes problems.

I'm only semi-literate in vba and vbscript and I've searched the net for hours looking for a solution. I don't care if the solution is some feature of Excel that I don't know about, or some clever vba procedure, or a vbscript, or even a bat file as long as I can offer my users a single-custom-icon-on-the-taskbar solution I'll be happy.

I've played with some vba code, but it doesn't get run before Excel already realizes that it's already running and displays a Yes-No Msgbox that is confusing to some of my users. Next I tried some vbscript ideas I found. I was able to start my workbook, but I couldn't get it to give it focus if it was already open.

Any ideas would be greatly appreciated.

AdTHANKSvance!

CodePudding user response:

This applies to VBScript and VBA.

Set WB = GetObject(WorkBook) - Switches to workbook if open or opens it if not.

Add Link

  1. Find and highlight desired file, the click [Bookmark...]

Bookmark

  1. Select the desired sheet.

SheetSelection

  1. Use away! Link should like like this:

Address Example

This will always open the file/Sheet if closed, and if not will activate it. Simple.

You can use the same hyperlink with VBA using Thisworkbook.followhyperlink "C:\Users\ccritchlow\Documents\A\Trial Space.xlsm#Sheet1!A1"

  • Related