Jump to content

Recommended Posts

Posted

I am trying to close an excel file that was not opened with _Excel_Open.  How do I found the excel application object?  I'm new and I am used to files and folders names, so an 'object' is new to me.  I have the info too and simply spy, but I don't know which info is the object name/string.  In the example from help doc's I see the code below and I tried justin pasting it into Scite.

<

Local $oExcel1 = ObjCreate("Excel.Application")
; Close the Excel instance which was not opened by _Excel_Open
; (will still be running because it was not opened by _Excel_Open)
_Excel_Close($oExcel1)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 1", "Error closing the Excel application." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Sleep(2000)
Local $aProcesses = ProcessList("Excel.exe")
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 1", "Function ended successfully." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel instance(s) still running.")
>

  • Moderators
Posted

@JNutt again, doing a little research will help you with these questions early on. AutoIt has a full range of Excel capabilities, all outlined in the help file. If you look at _Excel_BookAttach, you will see an example of attaching to a workbook object so you can then manipulate it as needed.

"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!

Posted
On 3/22/2018 at 12:53 PM, JLogan3o13 said:

I'm confused on how to reference the an Excel workbook that isn't open with _Excel_Open.  In the example for _Excel_BookAttach there is a variable set to a file, then a variable set to _Excel_Open and then a varialbe set to  _Excel_BookOpen wich references/calls the file and the _Excel_Open function.  In the code below I tried just using the workbook file name, but no luck.

<

; Attach to the first Workbook where the file path matches
$oWorkbook = _Excel_BookAttach("sheet1.xlsx")

_Excel_Close($oWorkbook)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 1", "Error closing the Excel application." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Sleep(2000)
Local $aProcesses = ProcessList("Excel.exe")
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 1", "Function ended successfully." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel instance(s) still running.")

>

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
×
×
  • Create New...