ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Exporting data to new instance of excel - created but not visible? (https://www.excelbanter.com/excel-programming/304371-exporting-data-new-instance-excel-created-but-not-visible.html)

Alan

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

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

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





Tom Ogilvy

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

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







Alan

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

"Tom Ogilvy" wrote in message
...

Set newxlApp = New Excel.Application
newxlApp.Visible = True


Doh!

Thanks Tom.




keepITcool

Exporting data to new instance of excel - created but not visible?
 
newXLapp.visible=true should do the trick

keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Alan" wrote:


Hi All,

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.


Any help is much appreciated,

Alan.


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

Private Sub cmdExportDatabase_Click()


Set newxlApp = New Excel.Application



End Sub

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






Alan

Exporting data to new instance of excel - created but not visible?
 
"keepITcool" wrote in message
...

newXLapp.visible=true should do the trick

keepITcool


Thanks - don't I feel a fool!





All times are GMT +1. The time now is 12:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com