Sign in to follow this  
Followers 0
mstr

Excel - There is something wrong?

7 posts in this topic

Can somebody tell me what's wrong?

#include <ExcelCOM_UDF.au3> ; Include the collection

$bedrijf = InputBox ("Stap 1", "Bedrijf:")
$plaats = InputBox ("Stap 2", "Plaats:")
$aantalpallets = InputBox ("Stap 3", "Aantal pallets:")
$leverdatum = InputBox ("Stap 4", "Leverdatum:")
$sFilePath = "palletbon.xls"

$oExcel = _ExcelBookOpen($sFilePath, $fVisible = 1)

_ExcelWriteCell($oExcel, $bedrijf, "B2")
_ExcelWriteCell($oExcel, $plaats, "B3")
_ExcelWriteCell($oExcel, $aantalpallets, "B4")
_ExcelWriteCell($oExcel, $leverdatum, "B5")
_ExcelWriteCell($oExcel, $bedrijf, "B8")
_ExcelWriteCell($oExcel, $plaats, "B9")
_ExcelWriteCell($oExcel, $aantalpallets, "B10")
_ExcelWriteCell($oExcel, $leverdatum, "B11")

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Sure, change line:

$oExcel = _ExcelBookOpen($sFilePath, $fVisible = 1)

to

$oExcel = _ExcelBookOpen($sFilePath, 1)

Will work :)

You must have copied it from UDF.

$bedrijf = InputBox ("Stap 1", "Bedrijf:")
$plaats = InputBox ("Stap 2", "Plaats:")
$aantalpallets = InputBox ("Stap 3", "Aantal pallets:")
$leverdatum = InputBox ("Stap 4", "Leverdatum:")
$sFilePath = "palletbon.xls"

$oExcel = _ExcelBookOpen($sFilePath, 1)

_ExcelWriteCell($oExcel, $bedrijf, "B2")
_ExcelWriteCell($oExcel, $plaats, "B3")
_ExcelWriteCell($oExcel, $aantalpallets, "B4")
_ExcelWriteCell($oExcel, $leverdatum, "B5")
_ExcelWriteCell($oExcel, $bedrijf, "B8")
_ExcelWriteCell($oExcel, $plaats, "B9")
_ExcelWriteCell($oExcel, $aantalpallets, "B10")
_ExcelWriteCell($oExcel, $leverdatum, "B11")
Edited by MadBoy

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

Why does he give me this error?

C:\Program Files\AutoIt3\Include\ExcelCOM_UDF.au3 (146) : ==> The requested action with this object has failed.: 
.WorkBooks.Open($sFilePath, Default, $fReadOnly) 
.WorkBooks.Open($sFilePath, Default, $fReadOnly)^ ERROR

And this is 146:

Func _ExcelBookOpen($sFilePath, $fVisible = 1, $fReadOnly = False)
    $oExcel = ObjCreate("Excel.Application")
    If NOT IsObj($oExcel) Then Return SetError(1, 0, 0)
    If NOT FileExists($sFilePath) Then Return SetError(2, 0, 0)
    If $fVisible > 1 Then $fVisible = 1
    If $fVisible < 0 Then $fVisible = 0
    With $oExcel
        .Visible = $fVisible
------»          .WorkBooks.Open($sFilePath, Default, $fReadOnly) «--------
        .ActiveWorkbook.Sheets(1).Select()
    EndWith
    Return $oExcel
EndFunc;==>_ExcelBookOpen

Share this post


Link to post
Share on other sites

Which autoit version are you using?


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

Just a small kick to solve this problem. :)

Share this post


Link to post
Share on other sites

Your problem is this line:

$sFilePath = "palletbon.xls"

You need to specify the exact location of the excel file like this:

$sFilePath = @ScriptDir & "\palletbon.xls"

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  
Followers 0