Hoth2001 Posted September 9, 2017 Posted September 9, 2017 I'm a newbie. And after watching an online tutorial for automating Excel I've written some simple code to open an excel workbook #include<Excel.au3> Local $oExcel_1 = _Excel_Open() Local $sWorkbook = "C:\Users\User\Desktop\CPMautomatorTest.csv" Local $oWorkbook = _Excel_BookOpen($oExcel_1,$sWorkbook) Next thing I want to do is delete Rows 2 through 10 in the workbook I've just opened. I'm not clear about the syntax and referring to the right objects. I Tried with this code: #include<Excel.au3> Local $oExcel_1 = _Excel_Open() Local $sWorkbook = "C:\Users\User\Desktop\CPMautomatorTest.csv" Local $oWorkbook = _Excel_BookOpen($oExcel_1,$sWorkbook) Local $oWorkbook = _Excel_RangeDelete($oExcel_1, "2:10") Which opens the workbook but does not delete the rows I want. Please help with the syntax error
Bowmore Posted September 9, 2017 Posted September 9, 2017 Have another read of the help file for _Excel_RangeDelete() It takes a worksheet object as the first parameter #include<Excel.au3> Local $oExcel_1 = _Excel_Open() Local $sWorkbook = "C:\Users\User\Desktop\CPMautomatorTest.csv" Local $oWorkbook = _Excel_BookOpen($oExcel_1,$sWorkbook) Local $result = _Excel_RangeDelete($oWorkbook.Worksheets("Sheet1"), "2:10") ;Deletes Rows 2 to 10 on Sheet1 "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
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