0
votes

I have a vbscript code to open the Outlook application but the problem that i am facing is that due to corporate policy, Macro setting is disabled (so i cannot select Enable all Macros) and every time the outlook is launched, it ask for enabling the outlook macro (which i have to do manually). Is there anyway to open outlook with enabling the outlook macro.

   Set objWMIService = GetObject("winmgmts:\\" & sComputerName & "\root\cimv2")
   sQuery = "SELECT * FROM Win32_Process WHERE Name LIKE '%outlook%'"
   Set objItems = objWMIService.ExecQuery(sQuery)
   'If 0 then it will open outlook
   if objItems.count = 0 then
     Set app = CreateObject("Shell.Application")
     app.ShellExecute "C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE", , ,, 3
     app.ActiveExplorer.Activate
   End if

Note: There might be some limitation of access due to corporate policy

enter image description here

1

1 Answers

0
votes

You can use the SendKeys method to press the required button programmatically. See VBScript - SendKeys Method for more information.