prasadstudy

Error: Variable used without being declared

5 posts in this topic

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?

Error.png

Share this post


Link to post
Share on other sites



The variable $bVisible came from the help file header; it doesn't exist in your code. Try changing your code to

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

 

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

#5 ·  Posted (edited)

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)

Sleep(1000)

_Excel_BookClose($oWorkbook)
_Excel_Close($oExcel)

 

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