Jump to content

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


ashly
 Share

Recommended Posts

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?

Link to comment
Share on other sites

Any Error messages?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 1 month later...

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
Link to comment
Share on other sites

  • Moderators

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.

"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

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.

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...