PDA

View Full Version : 2 Excel Files, 1 Userform



Kindly_Kaela
02-12-2007, 10:21 AM
Hi Everyone!

I have 2 LCD TV's hanging on the wall to display Excel graphs and charts. Both TV's are hooked up to the same computer. I want to have a different Excel application on each TV, and one user_form to manage both excel applications.

For demonstration purposes, let's say there's 2 excel files (Main.XLS and Second.XLS).

What would be an eligent way to write the code to easily switch between the 2 files, Dim statements and all?

Thanks!!
Kaela
:cloud9:

Bob Phillips
02-12-2007, 10:56 AM
What is wrong with just opening them in Excel as normal, and dragging them onto the appropriate monitor?

Kindly_Kaela
02-12-2007, 12:28 PM
I will be opening them in Excel and dragging them to seperate monitors.

The problem is the userforms. Both Excel's (on each monitor) put their userform at the same spot on the SAME monitor. So I figured one Userform that controlled both Excel's would be perfect.

Does that make sense?

I figured this would be an easy solution. Something cleaner then using....


Windows("Main.xls").Activate

malik641
02-13-2007, 08:06 AM
You can establish variables with both files if you want.
I don't know how to connect to another instance (Application) of Excel that's already opened, so I would suggest opening the main workbook and having the userform there then opening the second App and workbook by code so you can set the variable to that.
Public xlAppSecondary As Excel.Application
Public xlsMain As Excel.Workbook
Public xlsSecondary As Excel.Workbook

Public Sub SetConnections()
Dim strFullPathSecondary As String

strFullPathSecondary = "\\Server\Path\Secondary.xls (file://\\Server\Path\Secondary.xls)"

Set xlsMain = Application.Workbooks("Main.xls") ' Or Set xlsMain = Thisworkbook

Set xlAppSecondary = New Excel.Application
' Using readonly to open the secondary workbook. This is just incase it's already opened.
' If you know it's not already opened, just get rid of ReadOnly:=True
Set xlsSecondary = xlAppSecondary.Workbooks.Open(FileName:=strFullPathSecondary, ReadOnly:=True)

xlAppSecondary.Visible = True
End Sub

Untested...but it should work :)