Jump to content

Help excelcom_udf


Haugaard
 Share

Recommended Posts

#include <ExcelCOM_UDF.au3>; Include the function collection
$FopenMessage = "Chose the excel file that you want input from"
$Fopen = FileOpenDialog($FopenMessage, @WindowsDir & "\", "Excel file (*.xls)", 1 )
If @error Then
    MsgBox(4096,"","No File chosen")
EndIf

$oExcel = _ExcelBookOpen($Fopen); Open file

$SzData = InputBox("Data",@LF & @LF & "What colum shoul i use data from?:")

For $Cell = 1 To 999991
    WinActivate("Microsoft Excel - x805.xls");Activate Excel
    $exdata = _ExcelReadCell($oExcel, $Cell, $SzData);Read data
    If $ExData < 1  Then ExitLoop;Stop script if $data1 is = 9999999
    Sleep(1000)
    WinActivate("Session B - [24 x 80]");Activate AS400
    Send($ExData);Write the data from excel
    Sleep(500)
    Send("{ENTER}")
    Sleep(500)
    MouseClick("Left", 310, 61, 1);Mouseclick AS400 macro
    Sleep(500)
    Send("{ENTER}");Confirm use of macro
    Sleep(3500);Wait for the macro to run, big sleep
Next
Exit

Link to comment
Share on other sites

I fixed the input box so it doesn't throw an error, but I don't have the beta installed, so I don't know about the rest of your code:

#include <ExcelCOM_UDF.au3>; Include the function collection
$FopenMessage = "Browse for the input Excel file."
Do
    $Fopen = FileOpenDialog($FopenMessage, @WindowsDir, "Excel file (*.xls)", 1)
Until (Not @error)

$oExcel = _ExcelBookOpen($Fopen); Open file

$SzData = InputBox("Data", @CR & @CR & "What column should I use data from?")

For $Cell = 1 To 999991
    WinActivate("Microsoft Excel - x805.xls");Activate Excel
    $exdata = _ExcelReadCell($oExcel, $Cell, $SzData);Read data
    If $ExData < 1  Then ExitLoop;Stop script if $data1 is = 9999999
    Sleep(1000)
    WinActivate("Session B - [24 x 80]");Activate AS400
    Send($ExData);Write the data from excel
    Sleep(500)
    Send("{ENTER}")
    Sleep(500)
    MouseClick("Left", 310, 61, 1);Mouseclick AS400 macro
    Sleep(500)
    Send("{ENTER}");Confirm use of macro
    Sleep(3500);Wait for the macro to run, big sleep
Next
Exit

Das Häschen benutzt Radar

Link to comment
Share on other sites

I fixed the input box so it doesn't throw an error, but I don't have the beta installed, so I don't know about the rest of your code:

#include <ExcelCOM_UDF.au3>; Include the function collection
$FopenMessage = "Browse for the input Excel file."
Do
    $Fopen = FileOpenDialog($FopenMessage, @WindowsDir, "Excel file (*.xls)", 1)
Until (Not @error)

$oExcel = _ExcelBookOpen($Fopen); Open file

$SzData = InputBox("Data", @CR & @CR & "What column should I use data from?")

For $Cell = 1 To 999991
    WinActivate("Microsoft Excel - x805.xls");Activate Excel
    $exdata = _ExcelReadCell($oExcel, $Cell, $SzData);Read data
    If $ExData < 1  Then ExitLoop;Stop script if $data1 is = 9999999
    Sleep(1000)
    WinActivate("Session B - [24 x 80]");Activate AS400
    Send($ExData);Write the data from excel
    Sleep(500)
    Send("{ENTER}")
    Sleep(500)
    MouseClick("Left", 310, 61, 1);Mouseclick AS400 macro
    Sleep(500)
    Send("{ENTER}");Confirm use of macro
    Sleep(3500);Wait for the macro to run, big sleep
Next
Exit
That dient fix it, it is $szdata/inputbox that gives me the error
Link to comment
Share on other sites

This is the error i get:

Line 481 (File "C\ducuments and settings\thh\skrivebord\excelcom_udf.au3"):

Return $oExcel.actvesheet.cells($sRangeOrRow, $iColumn).Value
Return $oExcel.actvesheet.cells($sRangeOrRow, $iColumn)^ERROR

Error: The requested action with this object has failed.

$exdata = _ExcelReadCell($oExcel, $Cell, $SzData);Read data

Fails

$exdata = _ExcelReadCell($oExcel, $Cell, 3);Read data

Works

????

Link to comment
Share on other sites

This is the error i get:

Line 481 (File "C\ducuments and settings\thh\skrivebord\excelcom_udf.au3"):

Return $oExcel.actvesheet.cells($sRangeOrRow, $iColumn).Value
Return $oExcel.actvesheet.cells($sRangeOrRow, $iColumn)^ERROR

Error: The requested action with this object has failed.

$exdata = _ExcelReadCell($oExcel, $Cell, $SzData);Read data

Fails

$exdata = _ExcelReadCell($oExcel, $Cell, 3);Read data

Works

????

In many places (with native functions) AutoIt will do an implied Number() when you pass a string number vice and integer as a parameter. This almost never works with UDFs though, and you are safer never making that assumption. An InputBox() returns a string, and you should assume it needs Number() if you will use the returned value that way:

$SzData = Number(InputBox("Data", @CR & @CR & "What column should I use data from?"))oÝ÷ Øô¨­«­¢+ØÀÌØíMéÑô%¹ÁÕÑ    ½à ÅÕ½ÐíÑÅÕ½Ðì±1µÀì1µÀìÅÕ½Ðí]¡Ð½±Õ´Í¡½Õ°¤ÕÍÑɽ´üèÅÕ½Ðì¤(ÀÌØí¥Ñô9ÕµÈ ÀÌØíMéѤ)½ÈÀÌØí
±°ôÄQ¼äääääÄ(츸¸(ÀÌØíáÑô}á±I
±° ÀÌØí½á°°ÀÌØí
±°°ÀÌØí¥Ñ¤íIÑ(츸¸)9á

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...