Customise excel icon in taskbar on loading. I have half a solution, but need to know how to implement a VBS script to automate icon Pin/Unpin on Task Bar

On Windows7 operating system, I wish instances of myExcelProject.xlsm to have a distinctive icon in the task bar. This will distinguish my project from other excel files. My test icon graphic ( tstTaskBarIcon2.ico) is simply a green square. However, it has been uploaded with a 'make believe' jpg extension because an .ico extension is not accepted by the EE upload site. Nevertheless, this tstTaskBarIcon2.jpg IS in reality an .ico file, so if you need to open it, please EDIT the extension back to .ico.

I first used code in: http://stackoverflow.com/questions/20142765/how-to-change-the-excel-icon-in-taskbar-while-loading  (which is the attached file: myExcelProject.xlsm).  When initiated from ThisWorkbook.Workbook_Open, this code customised the icon that appears in the Task bar window THUMB NAIL file illustration, but the code did NOT customise the icon in the Taskbar TRAY. However,..

.. 'pinning' and then 'unpinning' the  ison in the Task bar TRAY DID cause the customised 'GREEN' icon to be displayed reliably, and exclusively for myExcelProject, and not for other xl files. Pinning/unpinning is required each time the file is opened. So, unless there is an alternative, I needed to automate 'pinning' and then 'unpinning'.

I found this code (copies at foot of this text):
http://www.codeproject.com/Articles/185512/Programmatically-PIN-shortcut-onto-Taskbar-on-Win

It is written in VBS script, and the file to be pinned/unpinned is:
LnkFile = Desktop.Self.Path&"\ScheduleNotifier.lnk"

I dont know VBS..
Do I run these scripts from Windows shell (which is new to me)?
Some pointers would be appreciated

Thanks
Kelvin

----FYI copied from: http://www.codeproject.com/Articles/185512/Programmatically-PIN-shortcut-onto-Taskbar-on-Win--

--------------- Pin to Taskbar ----------------
Option Explicit

'Const CSIDL_COMMON_PROGRAMS = &H17
Dim ShellApp, FSO, Desktop
Set ShellApp = CreateObject("Shell.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")

'Set StartMenuFolder = ShellApp.NameSpace(CSIDL_COMMON_PROGRAMS)
Set Desktop =  ShellApp.NameSpace("C:\Users\Wayne\Desktop")

Dim LnkFile
LnkFile = Desktop.Self.Path&"\ScheduleNotifier.lnk"

If(FSO.FileExists(LnkFile)) Then
    Dim tmp, verb
    'For Each verb in Desktop.ParseName("ScheduleNotifier.lnk").Verbs
        'tmp = tmp&verb&chr(13)
    'Next
    'MsgBox(tmp)

    Dim desktopImtes, item
    Set desktopImtes = Desktop.Items()

    For Each item in desktopImtes
        If (item.Name = "ScheduleNotifier") Then
            'MsgBox(item.Name)
            For Each verb in item.Verbs
                If (verb.Name = "Pin to Tas&kbar") _
            Then 'If (verb.Name = "锁定到任务栏(&K)")
                    verb.DoIt
                End If
            Next
        End If
    Next

End If

Set FSO = Nothing
Set ShellApp = Nothing

--------------- Unpin from Taskbar---------------


Option Explicit
'Const CSIDL_COMMON_PROGRAMS = &H17
Dim ShellApp, FSO, Desktop
Set ShellApp = CreateObject("Shell.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")

'Set StartMenuFolder = ShellApp.NameSpace(CSIDL_COMMON_PROGRAMS)
Set Desktop =  ShellApp.NameSpace("C:\Users\Wayne\Desktop")

Dim LnkFile
LnkFile = Desktop.Self.Path&"\ScheduleNotifier.lnk"

If(FSO.FileExists(LnkFile)) Then
    Dim tmp, verb
    'For Each verb in Desktop.ParseName("ScheduleNotifier.lnk").Verbs
        'tmp = tmp&verb&chr(13)
    'Next
    'MsgBox(tmp)

    Dim desktopImtes, item
    Set desktopImtes = Desktop.Items()

    For Each item in desktopImtes
        If (item.Name = "ScheduleNotifier") Then
            'MsgBox(item.Name)
            For Each verb in item.Verbs
                If (verb.Name = "Unpin from Tas&kbar") _
            Then 'If (verb.Name = "从任务栏脱离(&K)")
                    verb.DoIt
                End If
            Next
        End If
    Next

End If

Set FSO = Nothing
Set ShellApp = Nothing
myExcelProject.xlsm
tstTaskBarIcon2.jpg
Kelvin4Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Randy DownsOWNERCommented:
Maybe this will help.

I would ensure the code works by running it manually then run it via VBA.

Browse to the folder containing the script you want to run and double-click it. Script files can be listed in My Computer, Windows Explorer, the Find window, the Start menu, or on your desktop.
By using the Run command
Click Start, and then click Run. In Open, type the name of the Windows Host executable file (Wscript.exe), followed by a space, then the full path name of the script you want to run. Be sure to include the file name extension of the script file. Click OK to start the script.
From a command prompt window
At the command prompt, type the name of the Windows Host executable file (Wscript.exe), followed by a space, then the full path name of the script you want to run. Be sure to include the file name extension of the script file. Press Enter to start the script.
Note
•      
Windows scripts are files with the following file name extensions: .wsf, .vbs, .js.
•      
If you double-click a script file whose extension has not been associated with Wscript.exe, the Open With dialog box appears. Select Wscript.exe, then select Always use this program to open this file type. This registers Wscript.exe as the default script host for files of this file type.
•      
You can use the Windows Script Host Settings dialog box to set global scripting properties for all scripts that Wscript.exe runs on the local computer
•      
You can set properties for individual scripts. See Related Topics for information about how to do this.
•      
You can also use Windows Script Host to create .wsf script files, with which you can call multiple scripting engines and perform multiple jobs, all from one file.

Run VBS from VBA


Shell "wscript c:\null\a.vbs",vbNormalFocus

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kelvin4Author Commented:
Many thanks for exactly the kind of advice and background information I was seeking.
Kelvin
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.