Opening an excel sheet maximized

kipster1203

Registered User.
Local time
Today, 05:03
Joined
May 5, 2010
Messages
13
As the title says, I'd like to know what I need to change to make my excel document open maximized when I call it. Here's my code:

Code:
Private Sub Project_Summary_Click()
On Error GoTo Err_Project_Summary_Click
   
    Dim oXL As Object
    Dim sFullPath As String  

    DoCmd.SetWarnings False
    
            'Project Summary Report
            
            DoCmd.TransferSpreadsheet acExport, , "Status Report Query", "W:\edsplus\applications\0cmad\project summary.xls", True, "Query_Data"
 
            '   Create a new Excel instance
            Set oXL = CreateObject("Excel.Application")
     
            '   Full path of excel file to open
            sFullPath = "W:\edsplus\applications\0cmad\project summary.xls"
     
            '   Open it
            With oXL
                .Visible = True
                .Workbooks.Open (sFullPath)
            End With
            
    DoCmd.Close acForm, Me.Name

Exit_Project_Summary_Click:
    Exit Sub

Err_Project_Summary_Click:
    MsgBox Err.Description
    Resume Exit_Project_Summary_Click

End Sub

THANK YOU!!
 
To maximize the application:

oXL.WindowState = -4137

To maximize the worksheet within the application

oXL.ActiveWindow.WindowState = -4137
 
Couldn't you just shell to the worksheet itself?

ie..

Shell "c:\Program Files\Microsoft\Office12\Excel " & "C:\MyExcelFolder\MyExcelFile.xls",vbmaximized
 
Couldn't you just shell to the worksheet itself?

ie..

Shell "c:\Program Files\Microsoft\Office12\Excel " & "C:\MyExcelFolder\MyExcelFile.xls",vbmaximized

For just opening it you can, but you need the Office install path for that and it could be different on different machines. :)
 
Couldn't you just shell to the worksheet itsellf?

This would open an Excel session and workbook independent of the objects the code is working with. In this particular case that would not make much difference since that is the end of the code.

However it is sometimes necessary to maintain contol of the objects after Excel opens.
 

Users who are viewing this thread

Back
Top Bottom