PDA

View Full Version : To open Another Excel in a different Window using code



bryVA
07-31-2009, 11:54 AM
Hello all,

I have an excel program that has a userform that I use. When I need to open another excel file it hides behind the userform. I was wondering if I can place code in the excel file that has the userform to force excel to open a seperate window when opening a new excel file.

Is this possible?

Thanks for all your help guys,

-B

GTO
07-31-2009, 01:27 PM
Greetings B,

Not sure if this is what you mean, but if there's an advantage to keeping the userform displayed, you could either .Show the userform as vbModeless in order to be able to interact with the sheet(s) while the form is displayed, or, you could create a second instance of Excel.

Maybe something like:

Option Explicit

Private Sub CommandButton1_Click()
Dim XL As Excel.Application
Dim wb As Workbook

Set XL = New Excel.Application
XL.Visible = True
Set wb = XL.Workbooks.Open(ThisWorkbook.Path & "\Book2.xls")
Set wks = wb.Worksheets("Sheet1")
'... and so on...
End Sub


Does that help?

Mark

bryVA
07-31-2009, 01:34 PM
Thank you. That does help. One issue is when I open an excel file not from the userform but from a folder is there a way to force that file to open in a seperate window if I have my userform up.

I have links on my userforms to websites. Some of those websites have excel files that open when clicked on. I was wondering when I click on those links on the website and it opens excel that it does it in a new window.

I hope this make sense.

Again thanks for your help,

-B