Spawning Excel maximized with VB

  • Thread starter Thread starter Wayne Rouse
  • Start date Start date
W

Wayne Rouse

Hi,

I am sure someone else has run into a similar issue so I
thought I might ask for some advice. Below is a code
snipet. I am trying to make sure when my VB app opens
excel that it always opens EXCEL maximized. I need this
to happen from the VB side and not from an embedded vba
macro in the spreadsheet.

***********************************************
Private Sub OpenExcel()


Dim msExcelApp As Object
Dim msExcelMacro As Object

'Set the object
Set msExcelApp = GetObject("", "Excel.Application")

Set msExcelApp = GetObject("", "Excel.Application")
'Next parameter will be looked up from a database
instead of static
gsTemplateName = "D:\Projects\example.xls"

With msExcelApp
.Visible = True
.workbooks.Open (gsTemplateName)
'.WindowState = xlMaximized
End With

End Sub

************************************

I get an error trying to set my objects WindowState.

Any help would be appreciated.

Thanks,
Wayne
 
Hi Wayne,

Since you're automating Excel using Late Binding (not setting a reference to
the Excel type libraries), VB doesn't know what xlMaximized is. You should
use the actual value of that built-in constant instead: -4137.
 
Many thanks Jake!
-Wayne
-----Original Message-----
Hi Wayne,

Since you're automating Excel using Late Binding (not setting a reference to
the Excel type libraries), VB doesn't know what xlMaximized is. You should
use the actual value of that built-in constant instead: - 4137.

--
Regards,

Jake Marx
www.longhead.com




.
 
Back
Top