Home |
Search |
Today's Posts |
#1
![]()
Posted to comp.lang.basic.visual.misc,microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I wrote that simple program to get an idea how to work with Excel objects from VB. It should (and actually does) create a new Excel workbook with three worksheets named "1", "2" and "3" (in this order from left to right) and save it. Please look at the code below and let me know if this is a good way to do it. Is there a way (and need) to streamline the code? TIA '============================================ Dim xlApp As Excel.Application Dim xlWB As Excel.Workbook Dim xlWS As Excel.Worksheet Dim i As Integer Dim strFileName As String Dim bAlerts As Boolean On Error GoTo Quit Set xlApp = New Excel.Application xlApp.Visible = False xlApp.SheetsInNewWorkbook = 1 Set xlWB = xlApp.Workbooks.Add For i = 1 To 3 Set xlWS = xlWB.Worksheets.Add(After:=xlWB.Worksheets(i)) xlWS.Name = Str$(i) Next i bAlerts = xlApp.DisplayAlerts xlApp.DisplayAlerts = False xlWB.Worksheets("Sheet1").Delete xlWB.Worksheets(1).Activate ' strFileName = xlApp.GetSaveAsFilename strFileName = "C:\Temp\Temp.xls" xlWB.Close SaveChanges:=True, FileName:=strFileName xlApp.DisplayAlerts = bAlerts Quit: xlApp.Quit Set xlWS = Nothing Set xlWB = Nothing Set xlApp = Nothing '================================================= == |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
What does Show Ink in Excel, Review Tab, comment, do? | Excel Worksheet Functions | |||
review changes in workbook | Excel Discussion (Misc queries) | |||
i have a fax sent to me for review but i cant open its saying i n | New Users to Excel | |||
excel review bar | Excel Discussion (Misc queries) | |||
Is there a quick way to see which objects have code attached? | Excel Programming |