![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Location: Michigan, USA
Posts: 17
|
Hi,
I copied a code from a VB book to create a excel workbook. It works fine. I am going to launch this workbook automatically once this book was created. Could you teach me how to do it? Thank you very much. This code is as follow: Private Sub Form_Click() Dim obExcelApp As Object Dim obWorkSheet As Object Dim blnRunning As Boolean Dim fName As String On Error Resume Next Set obExcelApp = GetObject(, "Excel.Application") If Err.Number <> 0 Then Set obExcelApp = CreateObject("Excel.Application") blnRunning = False Else blnRunning = True End If obExcelApp.Workbooks.Add Set obWorkSheet = obExcelApp.ActiveSheet obWorkSheet.Activate obWorkSheet.Cells(1, 1).Value = "Last Name" obWorkSheet.Cells(1, 2).Value = "First Name" obExcelApp.Save ("c:VBCreated.xls") obExcelApp.ActiveWorkbook.Close False If Not (blnRunning) Then obExcelApp.Quit End If End Sub ssunchen |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi ssunchen
When you create an object via Ole, it is not visible by default. Edit your code as follows if you want to see the workbook. Comment out these lines of code:
and then add the following anywhere below your set statement:
Tom |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|