Hello,
From within a Word macro, how would I open two Excel workbooks each in it's
own visible Window?
Thanks for your help.
--
Programmer on Budget

RE: Open Excel Workbooks in separate windows by BudgetProgrammer

BudgetProgrammer
Tue Aug 12 13:09:06 PDT 2008

I should also Add that I'm checking to see if Excel was running already, so
that I won't inadvertantly close it if I run into a problem with this macro.
Here's some of the code I have related to the workbook opens:
'Start Excel
'If Excel is running, get a handle on it; otherwise start a new instance of
Excel
On Error Resume Next
Set obXlTestApp = GetObject(, "Excel.Application")
If Err Then
blXlExcelWasNotRunning = True
Set obXlTestApp = Excel.Application
End If

On Error GoTo Err_Handler


'Let the Excel application be visible to the user
obXlTestApp.Visible = True

'Open the workbook stored in "vrXlTestTemplateFullname" Note: Open uses the
Folder and Filename (FullName)
Set obXlTestFile = Workbooks.Open(FileName:=vrXlTestTemplateFullName)

'Save the template as a new file using "vrXlTestFullName" Note: Save and
SaveAs uses the Folder and Filename (FullName)
'By using SaveAs, the original template is automatically closed and does not
need to be closed "manually"
ActiveWorkbook.SaveAs FileName:=vrXlTestFullName

'Open the workbook stored in "vrXlTraceTemplateFullname" Note: Open uses the
Folder and Filename (FullName)
Set obXlTraceFile = Workbooks.Open(FileName:=vrXlTraceTemplateFullName)
'Save the template as a new file using "vrXlTraceFullName" Note: Save and
SaveAs uses the Folder and Filename (FullName)
'By using SaveAs, the original template is automatically closed and does not
need to be closed "manually"
ActiveWorkbook.SaveAs FileName:=vrXlTraceFullName

(bunch of code. If there's an error with text from the Word document,
control is transferred to the label "Err_Handler")

'If the workbook obXlTestFile was open (if it was Not Nothing), then close it.
If Not obXlTestFile Is Nothing Then
obXlTestFile.Close
End If

'If the workbook obXlTraceFile was open (if it was Not Nothing), then close
it.
If Not obXlTraceFile Is Nothing Then
obXlTraceFile.Close
End If

'If Excel was runing when this macro started, leave it running. There are
probably other workbooks open.
'If Excel was Not running when this macro started (blXlExcelWasNotRunning =
False) then quit Excel
If blXlExcelWasNotRunning = True Then
obXlTestApp.Quit
End If

'Set the Objects to "Nothing" to initialize the object
Set obXlTestApp = Nothing
'Set obXlTraceApp = Nothing
Set obXlTestFile = Nothing
Set obXlTraceFile = Nothing
Set obXlTestSheet = Nothing
Set obXlTraceSheet = Nothing
Set obXlRange = Nothing
Set obWdApp = Nothing
Set obWdDoc = Nothing

--
Programmer on Budget


"Budget Programmer" wrote:

> Hello,
> From within a Word macro, how would I open two Excel workbooks each in it's
> own visible Window?
> Thanks for your help.
> --
> Programmer on Budget

RE: Open Excel Workbooks in separate windows by GEBL

GEBL
Wed Aug 13 07:00:02 PDT 2008

For one Excel file

sub main
Dim objExcel As Object

Set objExcel = CreateObject("Excel.Application")
Set objExcel = GetObject("Path & Filename here")
objExcel.Application.Visible = True
objExcel.Parent.Windows(1).Visible = True

End Sub




"Budget Programmer" wrote:

> Hello,
> From within a Word macro, how would I open two Excel workbooks each in it's
> own visible Window?
> Thanks for your help.
> --
> Programmer on Budget

RE: Open Excel Workbooks in separate windows by BudgetProgrammer

BudgetProgrammer
Wed Aug 13 08:18:23 PDT 2008

Hello,
Thanks, but that did NOT open a separate instance of Excel, making the
second worksheet visible in its own distinct window. They run just like
before where I have to go the single instance of Excel and use the Windows
feature in there to view the two workbooks.
What I'm after is to have the Excel application appear twice on the Windows
Taskbar, each appliaction associated with a different workbook.
Many thanks for your help.
--
Programmer on Budget


"GEBL" wrote:

> For one Excel file
>
> sub main
> Dim objExcel As Object
>
> Set objExcel = CreateObject("Excel.Application")
> Set objExcel = GetObject("Path & Filename here")
> objExcel.Application.Visible = True
> objExcel.Parent.Windows(1).Visible = True
>
> End Sub
>
>
>
>
> "Budget Programmer" wrote:
>
> > Hello,
> > From within a Word macro, how would I open two Excel workbooks each in it's
> > own visible Window?
> > Thanks for your help.
> > --
> > Programmer on Budget

Re: Open Excel Workbooks in separate windows by james_davey1

james_davey1
Wed Aug 13 13:21:44 PDT 2008

i havent checked it out, but can you not just:

dim objxl as new excel.application

then open your workbook .... then just do it again for the second one?

RE: Open Excel Workbooks in separate windows by BudgetProgrammer

BudgetProgrammer
Wed Aug 13 14:53:01 PDT 2008

Hi,
That's what I've done, but it seems to open both in the same application.
I've Dim'ed two applications and tried to associate one workbook with each
application, but that doesn't seem to work either.
Thanks for looking into thtis
--
Programmer on Budget


"Budget Programmer" wrote:

> Hello,
> Thanks, but that did NOT open a separate instance of Excel, making the
> second worksheet visible in its own distinct window. They run just like
> before where I have to go the single instance of Excel and use the Windows
> feature in there to view the two workbooks.
> What I'm after is to have the Excel application appear twice on the Windows
> Taskbar, each appliaction associated with a different workbook.
> Many thanks for your help.
> --
> Programmer on Budget
>
>
> "GEBL" wrote:
>
> > For one Excel file
> >
> > sub main
> > Dim objExcel As Object
> >
> > Set objExcel = CreateObject("Excel.Application")
> > Set objExcel = GetObject("Path & Filename here")
> > objExcel.Application.Visible = True
> > objExcel.Parent.Windows(1).Visible = True
> >
> > End Sub
> >
> >
> >
> >
> > "Budget Programmer" wrote:
> >
> > > Hello,
> > > From within a Word macro, how would I open two Excel workbooks each in it's
> > > own visible Window?
> > > Thanks for your help.
> > > --
> > > Programmer on Budget

Re: Open Excel Workbooks in separate windows by Nick

Nick
Wed Aug 13 17:19:19 PDT 2008

Will setting the ShowWindowsInTaskbar property help?

Dim bShowInTaskbar as Boolean

bShowInTaskbar = objExcel.ShowWindowsInTaskbar
objExcel.ShowWindowsInTaskbar = True

' Do stuff

' Restore user's setting
objExcel.ShowWindowsInTaskbar = bShowInTaskbar


- Nick

Re: Open Excel Workbooks in separate windows by BudgetProgrammer

BudgetProgrammer
Thu Aug 14 09:27:00 PDT 2008

Nick,
That did it. Many thanks!
Phil
--
Programmer on Budget


"Nick Hebb" wrote:

> Will setting the ShowWindowsInTaskbar property help?
>
> Dim bShowInTaskbar as Boolean
>
> bShowInTaskbar = objExcel.ShowWindowsInTaskbar
> objExcel.ShowWindowsInTaskbar = True
>
> ' Do stuff
>
> ' Restore user's setting
> objExcel.ShowWindowsInTaskbar = bShowInTaskbar
>
>
> - Nick
>