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

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Force a File to Open in a New Excel Instance

Without this being done externally to VBA coding, this wouldn't be possible
given the instantiating issue that you face. This would be something that
would have to be done with some external code to first open a new instance
of Excel, then to open the file within it.

I also have faced a similar issue to this, but rather with the userform
coming up, which then for any other file to be opened up, they would have to
open up a second instance of Excel before they could try to open up any
other file. That is cause for as long as the userform is up for the one
file, no other file could be opened within that instance manually speaking
(from inside or from outside of that instance with the userform up).

Several operators has not liked this issue, and I have shown them numerous
times how to get around the issue, so as they can do other things as needed,
and yet, still be able to use the one file to record their production data.
One thing is, I don't have the code hide the application or anything of that
nature as the one time when I was running a test of that, it cased several
other issues down the road, such as the application not getting closed out
of memory like it should have.

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Force a File to Open in a New Excel Instance

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



  #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




Reply
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 01:29 PM.

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

About Us

"It's about Microsoft Excel"