strate Posted March 26, 2006 Share Posted March 26, 2006 Is it possible to find out if a document is already in use before you run a script? We have a file that is on our network. If somebody has it open, and I run my script it errors out due to the "This document is already in use" dialog. How can I get around this, or check for it? INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station... Link to comment Share on other sites More sharing options...
randallc Posted March 26, 2006 Share Posted March 26, 2006 Hi, What is your script? Are you using ExcelCom.au3? If so, can you tell me ; Does"_XLReadOnly" work for this? Or would that script help you with a workaround? Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
strate Posted March 26, 2006 Author Share Posted March 26, 2006 Hi, What is your script? Are you using ExcelCom.au3? If so, can you tell me ; Does"_XLReadOnly" work for this? Or would that script help you with a workaround? Best, RandallI'm such an idiot. I always take pieces from other scripts I have and make them work. I'll give it a try. Sounds like a solid answer to my problem. Anyways heres my code:expandcollapse popupIf @OSVersion <> 'WIN_XP' Then MsgBox(16+4096, "Ship-To #'s",'Error: This program is currently setup to be used on a '&@CRLF _ & ' Windows XP operating system only. Sorry for '&@CRLF _ & ' any inconvinence.') Exit EndIf Dim $MsgBox_Answer,$MsgBox_Answer,$ShipTo,$SO,$FilePath,$MyExcel,$oExcel $MyExcel = ObjCreate("Excel.Application"); Create an Excel Object $FilePath = 'G:\Packaging\Shared\Sales Order Lookup.xls' $MyExcel.Workbooks.open ($FilePath, 0) $oExcel = ObjGet($FilePath) While 1 $SO = InputBox("Ship-To #'s", 'Sales Order Number (without "SO")', '','',200,125) If @error = 1 Then ExitLoop If $SO = '' Then ContinueLoop $oExcel.activesheet.Range ("B1").value = 'so' & $SO $ShipTo = $oExcel.activesheet.range ('D4').value If $ShipTo = 0 Then MsgBox(16+4096, "Ship-To #'s",'Error: The sales order number you have entered is not on file.'&@CRLF _ & ' Sales Order: '&$SO &@CRLF &@CRLF _ & 'Fix: Alert shipping to this so that they can update the file' &@CRLF _ & ' if this is a proper sales order.'&@CRLF &@CRLF _ & ' File is located at: ' &@CRLF _ & ' G:\Packaging\Shared\Sales Order Lookup.xls') Else $MsgBox_Answer = MsgBox(65, "Ship-To #'s", 'Sales Order Number: ' & $SO & @CRLF & 'Ship-To Number : ' & $ShipTo) EndIf If $MsgBox_Answer = 2 Then ExitLoop $MsgBox_Answer = '' $ShipTo = '' $SO = '' WEnd $oExcel.saved = 1; Prevent questions from excel to save the file $oExcel.close (0) $MyExcel.quit $MyExcel = '' INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now