Contributed By: Marcus Tettmar [email protected]
Submitted On: 21/02/03
VBSTART
Sub ExcelExample
Dim xlApp
Dim xlBook
Dim xlSheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlApp.visible = True
'optionally make the sheet visible
'xlSheet.Application.Visible = True
xlSheet.Cells(1,1).Value = "This is the column A, row 1"
'etc
xlSheet.SaveAs "C:\files\mysheet.xls"
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
VBEND
VBRun>ExcelExample
Automate Excel with VBScript
Moderators: Dorian (MJT support), JRL, Phil Pendlebury
- Marcus Tettmar
- Site Admin
- Posts: 7381
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
-
- Newbie
- Posts: 2
- Joined: Fri Jul 20, 2012 10:15 pm
Re: Automate Excel with VBScript
can you explain this a little better?mtettmar wrote:Contributed By: Marcus Tettmar [email protected]
Submitted On: 21/02/03
VBSTART
Sub ExcelExample
Dim xlApp
Dim xlBook
Dim xlSheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlApp.visible = True
'optionally make the sheet visible
'xlSheet.Application.Visible = True
xlSheet.Cells(1,1).Value = "This is the column A, row 1"
'etc
xlSheet.SaveAs "C:\files\mysheet.xls"
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
VBEND
VBRun>ExcelExample
- Marcus Tettmar
- Site Admin
- Posts: 7381
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Well, microsoft might be the best people to explain it. Which bit do you want help with? The Excel COM object reference is here:
http://msdn.microsoft.com/en-us/library ... s.80).aspx
http://msdn.microsoft.com/en-us/library ... s.80).aspx
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?
-
- Newbie
- Posts: 2
- Joined: Fri Jul 20, 2012 10:15 pm