Jump to content
Sign in to follow this  
Spiff59

Excel - Multiple opens causing orphan files in "My Documents"

Recommended Posts

Spiff59

My application opens existing Excel workbooks across a network via an Autoit front-end.

Apparently, some conbination of re-running the Autoit Script (an .exe) or, some combination of executing Excel from within my Autoit program is causing copies of Excel workbooks stored on a network drive to appear locally in everyones "My Documents" folders. I'd like to simply make the Excel window and workbook active if it is already open, or open additional workbooks in the same instance of Excel if they request a differnt workbook. Of course, the third option is if they have no Excel windows open , to open one with the requested workbook (that's the easy part!).

Any examples of code for proper file handling to keep from having multiple copies of the same workbook open? Yet, allow multiple (different) workbooks to open in the same Excel window?

I've been playing with the 'attach' and 'show' functions without much success.

Thank you!

Share this post


Link to post
Share on other sites
TnTProductions

was there really a need to post this twice in a row....


"FREEDOM is not FREE""Its a good thing war is so terrible, or we grow too fond of it" -Robert E. Lee[quote]Firestrom: global $warming = False[/quote]My scripts:Desktop Cleaner---->Total Downloads:167;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;111111;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;"a wise man once said why use your skills when we have technology"

Share this post


Link to post
Share on other sites
Spiff59

was there really a need to post this twice in a row....

I forgot tag the "email notification" box, I hurriedly checked it and resubmitted. I half expected to find a dupe to delete, but it was not showing when I got back to the forum. So, I apologize for accidentally sending out a worthless post (as opposed to intentionally doing so, like some people do <hint>). Edited by Spiff59

Share this post


Link to post
Share on other sites
Spiff59

I gutted my app down to the following routine.

When run, it will leave you with copies of all the accessed Excel files sitting in your 'My Documents' folder.

From the documentation, what I was doing seemed pretty straightforward. I thought perhaps it was OS-related, since I was running on Serverr 2003 x64 SP2, but I got the same behavior when ran on XP Pro SP2. I'm either improperly using the Excel functions (leaving out a step or parm?), or maybe it's a timing issue where my loop needs a pause?

Any help is appreciated.

(You'll of course have to create dummy spreadsheets as 1.xls, 2.xls, 3.xls and 4.xls in your root directory if you want to try it for yourself).

; IDENTIFICATION DIVISION
$AppName = "Excel test"

===========================================
; ENVIRONMENT DIVISION

===========================================
; DATA DIVISION
#include <ExcelCOM_UDF.au3> 

===========================================
;PROCEDURE DIVISION
for $x = 1 to 4
    Access_Workbook()
Next
Exit

-----------------------------------------------------------------------------
Func Access_Workbook()
    $FilePath = "C:\" & $x & ".xls" 
    $oExcel = _ExcelBookOpen($FilePath, 0, 1, "", "")
    $Cell1 = _ExcelReadCell($oExcel, 1, 1)
    $Cell2 = _ExcelReadCell($oExcel, 2, 1)
    _ExcelBookClose($oExcel)
EndFunc

(Ignore the comments... just being silly)

Edited by Spiff59

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  

×