Posted to microsoft.public.excel.programming
|
|
Exporting data to new instance of excel - created but not visible?
Set newxlApp = New Excel.Application
newxlApp.Visible = True
--
Regards,
Tom Ogilvy
"Alan" wrote in message
...
Hi All,
I am using the code below upon the click event of a command button in
a userform to export a database to an new excel workbook.
I want it to be a new instance of excel so that the user can Alt-Tab
between the open system (controlled by userform 'menus') and the
export.
The code runs okay, but it seems to create a new instance of excel
that is not visible in windows. I can see it from the process list
and I can kill it from there, but I want the user to be able to see it
and Alt-Tab between it and the original instance.
I found a reference to something similar in this group from 2001 (Tom
Ogilvy) so I removed my WITH constructs but no improvement (see
commented out WITHs in the code below):
http://groups.google.co.nz/groups?hl...%40tkmsftngp03
Any help is much appreciated,
Alan.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Private Sub cmdExportDatabase_Click()
Set newxlApp = New Excel.Application
Set newBook = newxlApp.Workbooks.Add
newBookName = ("Export as at " & Format(CDate(Now()), "HHMM DDDD D
MMM YYYY"))
' With newBook
newBook.Title = newBookName
newBook.Subject = "Inventory"
newBook.SaveAs Filename:=newBookName
' End With
Application.Workbooks("Inventory
System.xls").Worksheets("Database").Activate
Cells.Select
Selection.Copy
' With newBook
newBook.Worksheets("Sheet1").Activate
newBook.Worksheets("Sheet1").Range("A1").Select
Selection.PasteSpecial
newBook.Worksheets("Sheet1").Cells.Validation.Dele te
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AutoFilter
Range("A1").Copy Range("A1")
Range("A1").Select
' End With
Application.Workbooks("Inventory
System.xls").Worksheets("Active").Activate
MsgBox ("Database exported")
End Sub
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|