Jump to content

Error: Variable used without being declared

Recommended Posts


I am getting the following error "Variable used without being declared" while using the below 

Global $OpenExcel=_Excel_Open()
Global $ReferenceWorkBook=_Excel_BookOpen($OpenExcel,$Referencepath,$bVisible=False)

Code seems to be fine according to me and not sure why this error keeps popping up. Any assistance?


Share this post

Link to post
Share on other sites

Thanks @Danp2 for the reply!!!

What I wanted is to open an excel sheet and make it invisible (Running behind current active window). 

Per your assistance, I had tried with marking it as "False" directly but excel sheet did not go behind current active window.

Also, having an another query, if we pass directly as "False" in the argument, then how does system understands that this argument is for $bVisible and not for $bReadOnly?

_Excel_BookOpen ( $oExcel, $sFilePath [, $bReadOnly = False [, $bVisible = True [, $sPassword = Default [, $sWritePassword = Default [, $bUpdateLinks = Default]]]]] )

I tried again by matching with above format but ended up with error messages only.

Global $ReferenceWorkBook=_Excel_BookOpen($OpenExcel,$Referencepath,,False) - Error in expression.

Global $ReferenceWorkBook=_Excel_BookOpen($OpenExcel,$Referencepath,[,[,False]]) - Error in expression.



Share this post

Link to post
Share on other sites

You cannot leave parameters blank, you have to put in either True or False (or the Default keyword) for the $bReadOnly param:

#include <Excel.au3>

Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, @DesktopDir & "\Test.xlsx", Default, False)




Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post

Link to post
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