Weird issue when trying to open Excel Application from VBScript especially when the script is not running with elevated access/privileges


Local time
9:35 PM
Posts
1
OS
Windows 11
As I mentioned in the Q-title, I have a VBScript which I am sure was working fine in Windows 10 with
Code:
Microsoft® Excel® LTSC MSO (Version 2205 Build 16.0.15225.20278) 64-bit
Excel version and once I made sure that
Code:
ClickToRunSvc
service was running, and then when I ran this VBScript(without any elevation) it did open any Excel secured sheet with password, so that I didn't have to enter password everytime I wanted to open the sheet(I know not very secure, but this is my system behind firewall, so not much worried about it there).:
Code:
Sub OpenChosenLockedSheet(ChosenFile)
    AdminElevate
Set objExcel = CreateObject("Excel.Application")
objExcel.SendKeys "% x" : objExcel.Visible = True : objExcel.SendKeys "% x"
CreateObject("Wscript.Shell").AppActivate GetObject(, "Excel.Application").Caption
Set objWorkbook = objExcel.Workbooks.Open(ChosenFile, , , ,"<password>")
Set objExcel = Nothing : Set objWorkbook = Nothing
End Sub

But now after fully upgrading the OS to Windows 11, this same above script, running with same Office Excel version, doesn't open the Excel.Application at all and throws the below(also very infamous) error, unless I self-elevate the above script(that's why
Code:
AdminElevate
is uncommented) and open the secured sheet:
Code:
Error: ActiveX component can't create object: 'Excel.Application'
Code: 800A01AD

So my query: Is this part of bigger change Microsoft made when it rolled out Windows 11 and I missed or there needs to be some extra coding or quick-fix done to make this script work without admin-elevation ? Anyone feel free to help out.
 
Windows Build/Version
11

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo Laptop
Even on Windows 10 that script fails for me at the line AdminElevate, which is not a vbs function.
I see the same error whether I run as std or as Admin.
It works correctly if I bypass the AdminElevate line.

Had you perhaps previously been running that script within a larger script that defined an AdminElevate function?

Best of luck,
Denis
 
Last edited:

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3296

Latest Support Threads

Back
Top Bottom