Spawning Excel maximized with VB

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
 
J

Jake Marx

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.
 
W

Wayne Rouse

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




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top