My goal is to add a icon to my toolbar in the quick access section.
I wish this code could look at the file that is open, check if the file name contains or rather look likes this "_pr11.xlsx". If so, I want my code to save file as, see code below, and otherwise do or actually run/start an application. If the application is already running, I would like the code to do nothing of course, or say it could do a msgbox.
Obviously I can not archive this and maybe its not even possible? Is any of this scenario even doable?
I would much appreciate all the help and guidance so thanx in advance!
Sub IfOpenFileIs_PR11RepportThen()
If ActiveWorkbook.name 'ends with' = "*_pr11*.xlsx" Then
ActiveWorkbook.SaveAs Filename:="C:\Temp\PR11\" & "R11 (P3)" & " fram t.o.m. " & Format(Now - 1, "YYYY-MM-DD"), FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
Else
if 'application is alreay running then
MsgBox "Generera en ny PR11 (P3) rapport"
Else
Dim strAppPath As String, varApp As Variant
strAppPath = "C:\Program Files (x86)\Citrix\ICA Client\SelfServicePlugin\SelfService.exe" -launch -reg "Software\Microsoft\Windows\CurrentVersion\Uninstall\intern-581c115@@Z47F003.W2K16 - Agresso_1" -startmenuShortcut"
varApp = Shell(strAppPath, 1)
End If
End If
End Sub