View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Opening in a new book

This might get you started--but I think it's a mistake!

Option Explicit
Sub testme()

Dim curWkbk As Workbook
Dim myFileName As Variant
Dim xlApp As Excel.Application

myFileName = Application.GetOpenFilename(filefilter:="Excel files, *.xls")

If myFileName = False Then
Exit Sub 'user hit cancel
End If

Set curWkbk = Nothing
On Error Resume Next
Set curWkbk = ActiveWorkbook
On Error GoTo 0

If curWkbk Is Nothing Then
Set xlApp = Application
Else
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
End If

xlApp.Workbooks.Open Filename:=myFileName

End Sub


Notice that in that new instance, none of your addins got loaded. (You'll have
to load them yourself.) And you'll have to make sure this code is available in
every instance of excel that you start--so you can reuse it.

I surely wouldn't do this.



ceemo wrote:

I was hoping to be able to do this using code. Perhaps a piece of code
that on work book open checks to see how many books are open if more
than one if then runs code to open it in a new excel application and
close the current spreadsheet.

--
ceemo
------------------------------------------------------------------------
ceemo's Profile: http://www.excelforum.com/member.php...o&userid=10650
View this thread: http://www.excelforum.com/showthread...hreadid=396806


--

Dave Peterson