Sign in to follow this  
Followers 0
ashly

Why i can't open other excel files when running a script accessing an excel

9 posts in this topic

i have an autoit script to access A.xls like below

_ExcelBookOpen("A.xls")

no matter invisibly or visibly with the flag, if i open other files (B.xls, C.xls...) then the script will crash

is it a known issue or i have done something wrong?

Share this post


Link to post
Share on other sites



Any Error messages?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

it seems like only happen when reading the value from cells

if i only open an excel and do nothing then i could open any other files i want

then i found other guys can run my script and open other files successfully

why??? is there any setting i need to modify for my computer?

my simple scripts:

#include <Excel.au3>

$oExcel_DM = _ExcelBookOpen(@ScriptDir &amp; "Result.xls", 0)

$iCol_DM = $oExcel_DM.Cells.SpecialCells($xlCellTypeLastCell).Column

$iRow_DM = $oExcel_DM.Cells.SpecialCells($xlCellTypeLastCell).Row

For $i = 1 To $iCol_DM

For $j = 1 To $iRow_DM

;MsgBox(0, "", $i &amp; "," &amp; $j)

_ExcelReadCell($oExcel_DM, $j, $i)

Next

Next

_ExcelBookClose($oExcel_DM, 0)

the error message is like below:

AutoIt3IncludeExcel.au3 (694) : ==> The requested action with this object has failed.:

Return $oExcel.Activesheet.Cells($sRangeOrRow, $iColumn).Value

Return $oExcel.Activesheet.Cells($sRangeOrRow, $iColumn)^ ERROR

open defferent excel will cause different error

AutoIt3IncludeExcel.au3 (194) : ==> Error in expressi&#111;n.:

For $i = 1 To .ActiveWorkbook.Sheets.Count

For $i = 1 To .ActiveWorkbook^ ERROR

Edited by ashly

Share this post


Link to post
Share on other sites

Do you manually edit the workbook while the script is running?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I just double click to open other excel then the script crashed.

Share this post


Link to post
Share on other sites

I can recreate this behaviour.

The problem might be caused by the UDF working with the activeworkbook/activeworksheet only. When you open another xls file during processing the activeworkbook/activeworksheet changes and hence the script crashes.

You can avoid the problem by starting a second instance of Excel and then opening the second workbook.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hi Guys,

I don't get an error, however the issue that I have when exporting to Excel is that if I open an Excel document the script writes to the file that was opened.

If I open a new Excel document the script continues without an issue.

Running on Win XP Pro SP3 with Office 2010.

Edited by CoolDude69

Share this post


Link to post
Share on other sites

CoolDude69, since your issue is not the same, rather than hijacking the thread why not create your own, with a descriptive title and explanation of what you're trying to accomplish. I promise you will receive support more quickly that way.


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

Share this post


Link to post
Share on other sites

CoolDude69, since your issue is not the same, rather than hijacking the thread why not create your own, with a descriptive title and explanation of what you're trying to accomplish. I promise you will receive support more quickly that way.

Hi JLogan,

I have the same problem only I don't get an error; I cannot Run Excel when exporting with AutoIT. The application crashes, this is why I used this thread. I do apologize I did not want to hijack the thread.

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
Sign in to follow this  
Followers 0