Jump to content

Error: Variable used without being declared


 Share

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?

Error.png

Link to comment
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.

 

 

Link to comment
Share on other sites

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...