on 03-11-2016 2:00 AM
Hello community!
Error while trying to attach an Excel spreadsheet by _Excel_BookAttach () function AutoIt the sheet was opened by an SAP transaction, so I'm using only the _Excel_Open () function but this returning an intermittent error in my script, does anyone can me help out?
Global $aWins = WinList ($sSAP_Excel_Temp)
_ArrayDisplay ($aWins)
$oWorkBook = _Excel_BookAttach ($aWins[1] [0], "Title")
Error = "1 - An error occurred or $ sString can not be found in any of the open workbooks @extended is Set to the COM error code."
@Error = 1 @ extended = -2147352570
I believe I'm using the same resource mentioned in this link:
http://help.sap.com/saphelp_afs64/helpdata/ja/e3/41a138c4397a42e10000009b38f842/content.htm
Thank you so much!
Márcio.
Hello Stefan,
I found an article that explains exactly where I'm stuck!
http://help.sap.com/saphelp_afs64/helpdata/ja/b7/989d37d373243de10000009b38f8cf/content.htm
After clicking the "Export List Object to XXL" I choose the option: Table, automatically opens a excel window with the SAP data, but I can not access with _Excel_BookAttach () not even get the name using the function _excel_BookList ()
* My main goal is to copy the data from the Excel window and paste it into MS Word and then format and print.
You have any other alternative? I believe not be possible to attach the spreadsheet with _Excel_BookAttach () function.
Once again thank you for your attention ever.
Márcio.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Holger Kohn,
It is exactly what I'm trying to do through the AutoIt, but not yet succeeded.
You would have to help me.
Thank you very much!
Marcio.
Hello Marcio,
try this to attach to an open Excel workbook:
;-Begin-----------------------------------------------------------------
;-Includes------------------------------------------------------------
#include "Array.au3"
#include "Excel.au3"
;-Main----------------------------------------------------------------
$aWorkBooks = _Excel_BookList()
;_ArrayDisplay($aWorkBooks)
For $i = 0 To UBound($aWorkBooks) - 1
If StringInStr(String($aWorkBooks[$i][1]), "Mappe1") Then
$oWorkBook = _Excel_BookAttach($aWorkBooks[$i][2] + "\" + _
$aWorkBooks[$i][1])
EndIf
Next
;-End-------------------------------------------------------------------
With _Excel_BookList you get all open workbooks. Loop over all open workbooks and find the right workbook based on a substring of the title. Attach to this workbook via path and name of the workbook.
Let us know your results.
Cheers
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Marcio,
please have a closer look to the _Excel_BookList function of AutoIt. It scans the class ID {00020819-0000-0000-C000-000000000046} = Microsoft.Office.Interop.Excel.WorkbookClass. If you open an Excel instance you should find an open workbook. It is weired that you can't find any open workbook.
Let us know your results.
Cheers
Stefan
Hello Stefan,
The _Excel_BookList () function does not find an open instance of the SAP GUI.
I found an Excel process in the task manager, but _Excel_BookList () function found nothing.
Like I already said before ...
...I found an article that explains exactly where I'm stuck!
http://help.sap.com/saphelp_afs64/helpdata/ja/b7/989d37d373243de10000009b38f8cf/content.htm
Muito obrigado!
Márcio.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.