I am running a query from an Informix database and dumping into excel.
The following is my script so far. It gets as far as running the query, but then I want it to delete the first row and reformat column C. It never gives me an erro, but it also never performs the row delete or the column format?
//Specify the path of the Excel file here
Let>filename=C:\Documents and Settings\D800\My Documents\SOC File\Fuel Price Project\Fuel Cost Query.dqy
IfFileExists>filename
ExecuteFile>filename
WaitWindowOpen>Microsoft Excel -*
Wait>20
VBSTART
Sub Deleterow()
'
' Deleterow Macro
' Macro recorded 1/30/2006 by D800
'
Rows("1:1").Select
Selection.delete xlShiftUp
Columns("C:C").Select
Selection.NumberFormat = "yyyy-mm-dd hh:mm:ss"
End Sub
VBEND
New at this - need excel query script help
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Hi,
You seem to have pasted Excel VBA code into your Macro Scheduler script expecting it to know what to do with it. As your code is there is nothing telling Macro Scheduler it has anything to do with Excel, so it will do nothing.
Here's a simple example which will delete the first row in an Excel sheet:
//PUT THE VBSTART-VBEND BLOCK AT THE TOP OF YOUR SCRIPT
VBSTART
Sub Deleterow()
Dim xlApp
Dim xlBook
Dim xlSheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.open("d:\test1.xls")
Set xlSheet = xlBook.Worksheets("Sheet1")
xlApp.visible = True
'xlSheet.Rows("1:1").Select
'xlSheet.Selection.delete xlShiftUp
xlSheet.Rows("1:1").delete 1
xlSheet.Columns("C:C").NumberFormat = "yyyy-mm-dd hh:mm:ss"
End Sub
VBEND
//THIS LINE OPENS XL AND DELETES THE ROW
VBRun>Deleterow
Make sure you change the Set xlBook and Set xlSheet lines to reflect the filename and sheet name.
You seem to have pasted Excel VBA code into your Macro Scheduler script expecting it to know what to do with it. As your code is there is nothing telling Macro Scheduler it has anything to do with Excel, so it will do nothing.
Here's a simple example which will delete the first row in an Excel sheet:
//PUT THE VBSTART-VBEND BLOCK AT THE TOP OF YOUR SCRIPT
VBSTART
Sub Deleterow()
Dim xlApp
Dim xlBook
Dim xlSheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.open("d:\test1.xls")
Set xlSheet = xlBook.Worksheets("Sheet1")
xlApp.visible = True
'xlSheet.Rows("1:1").Select
'xlSheet.Selection.delete xlShiftUp
xlSheet.Rows("1:1").delete 1
xlSheet.Columns("C:C").NumberFormat = "yyyy-mm-dd hh:mm:ss"
End Sub
VBEND
//THIS LINE OPENS XL AND DELETES THE ROW
VBRun>Deleterow
Make sure you change the Set xlBook and Set xlSheet lines to reflect the filename and sheet name.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Thank You this was very helpful!
Thanks!

