mstr Posted September 13, 2007 Posted September 13, 2007 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")
MadBoy Posted September 13, 2007 Posted September 13, 2007 (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 September 13, 2007 by MadBoy My little company: Evotec (PL version: Evotec)
mstr Posted September 13, 2007 Author Posted September 13, 2007 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
MadBoy Posted September 13, 2007 Posted September 13, 2007 Which autoit version are you using? My little company: Evotec (PL version: Evotec)
mstr Posted September 14, 2007 Author Posted September 14, 2007 Just a small kick to solve this problem.
DjDeep00 Posted September 14, 2007 Posted September 14, 2007 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"
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now