Jump to content

Error when run as a admin, Error on a line of code that does not exist (Error: Variable must be of type "Object") - (Moved)


Garcia
 Share

Recommended Posts

Hello everyone, my problem is that when I try to run my already compiled program as administrator I get this error, but when I run the script it works correctly.

image.png.68a8c3ce16238efeac3e20c14e67f71c.png

this is my code

#include <MsgBoxConstants.au3> 
#include <Excel.au3>

;I use this code to not open a new excel file
Global $sWorkbook = @ScriptDir & "\facturacion.xlsx"
Global $oWorkbook = _Excel_BookAttach($sWorkbook)

;this line of code is the problem
$num = $oWorkBook.ActiveSheet.Range("C2").value

MsgBox(0,0, $num)

;this line of code is the problem
$num = $oWorkBook.ActiveSheet.Range("C2").value

 

Is there another way to obtain the data from a cell in an Excel file?

Thanks for your time 😊

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

when you run the program "as-administrator", it's in a different security context. (UAC elevated)

 

If you must attach, because you need that particular workbook opened in Excel, then start Excel UAC elevated as well.

 

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...