Exporting data to new instance of excel - created but not visible?

  • Thread starter Thread starter Alan
  • Start date Start date
A

Alan

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=en&lr=&ie=UTF-8&selm=#Wjlvt43AHA.1264@tkmsftngp03

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.Delete


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

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top