Jump to content

Excel - There is something wrong?


mstr
 Share

Recommended Posts

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")
Link to comment
Share on other sites

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)

Link to comment
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
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...