LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Force a File to Open in a New Excel Instance

Thanks Peter,

That is right along the lines of what I was thinking. I really appreciate
your help.

Brandt

"Peter T" wrote:

Sounds like a dreadful arrangement. What you ask can be done though but
don't send a file to me that includes the following !

' normal module

Sub auto_open()
'Stop ' for testing

Application.Visible = True ' for testing

If Application.Workbooks.Count = 1 Then
Application.OnTime Now, "ShowForm"
Else
With CreateObject("excel.application")
.Visible = True
.DisplayAlerts = False
Call .Workbooks.Open(ThisWorkbook.FullName, , True)
.ActiveWorkbook.RunAutoMacros xlAutoOpen
End With
ThisWorkbook.Close False
End If

End Sub

Sub ShowForm()
UserForm1.Show
'Stop ' for testing
Application.Quit

End Sub


' userform code
Private Sub UserForm_Activate()
Dim s As String
s = Me.Caption
Me.Caption = "somethingUnique"
AppActivate Me.Caption
Me.Caption = s
End Sub

Private Sub UserForm_Initialize()
Application.Visible = False
End Sub

Private Sub UserForm_Terminate()
Application.Visible = True 'for testing
End Sub


The above is quickly cobbled together and only lightly tested.

At first uncomment those Stops, later re-comment and also the lines that
make the instance visible. If want to open the wb with code but don't want
to run the open event, hold Shift. Ensure multiple wb's are open in the
primary instance for testing..

You might want to find examples in this ng to include something so you can
reactive the form when it gets hidden.

Regards,
Peter T


"Brandt" wrote in message
...
I have a file that, when opened, hides the main excel window and shows a
userform and runs some code. The form is intended to be left open for
extended periods of time. This becomes problematic if the user opens the
file when they already have another excel file open because my file hides
their file until they close the userform. I have tried various things to

get
around this, but what I would really like to do is have my file first

check
to see if it is the only file open in the current instance, and if not
"re-open" itself in a new instance before the rest of the code is run. Is
this possible to have a file close itself in one instance and open itself

in
another one?

Thanks for any help

Brandt




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open new instance of excel every time I click file VIPGeorge Excel Discussion (Misc queries) 5 August 16th 12 07:57 PM
How to open a new instance of EXCEL and .xls file Launchnet Excel Worksheet Functions 10 June 19th 07 03:45 PM
Open new instance of excel 2007 every time I click file Brian Excel Discussion (Misc queries) 0 April 10th 07 08:16 PM
I would like to open a new instance of Excel each time I double-click on a xls file Mark Excel Worksheet Functions 4 September 1st 05 02:29 PM
Force a new Excel instance Marcelo[_7_] Excel Programming 2 August 26th 04 05:08 PM


All times are GMT +1. The time now is 06:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"