PDA

View Full Version : [SOLVED:] Maximum workbook and set to page layout view



dbowlds
07-01-2018, 04:14 PM
Hello, I have a Word VBA which creates an Excel spreadsheet.
However, I cannot for the life of me figure out how to make the workbook display maximized and also change to page layout view.
Instead, it shows up as a small window, and in Normal view.
I have tried everything I can think of, and have Googled, and all the code I find indicates that what I have should work, but it doesn't.

Can anyone please help me? What I thought should be simple has become quite frustrating.


Private Sub ExcelMax()
Dim ExcelApp As Object, ExcelWB As Object, ExcelWS As Object
Dim StrOut As String
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = False
Set ExcelWB = ExcelApp.Workbooks.Add
ExcelApp.Visible = True
Set ExcelWS = ExcelWB.Sheets(1)
ExcelWB.Activate
Application.WindowState = xlMaximized
ActiveWindow.View = xlPageLayoutView
End Sub

Sincerely,
Doug

Paul_Hossler
07-01-2018, 04:52 PM
Try this Word macro






Option Explicit

Sub ExcelMax()
Dim ExcelApp As Object, ExcelWB As Object, ExcelWS As Object
Dim StrOut As String, strCaption As String

Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = False
Set ExcelWB = ExcelApp.Workbooks.Add
ExcelApp.Visible = True

strCaption = ExcelApp.Caption

Set ExcelWS = ExcelWB.Sheets(1)

AppActivate strCaption

ExcelApp.WindowState = -4137 'xlMaximized
ExcelApp.Windows(1).View = 3 'xlPageLayoutView
End Sub

dbowlds
07-02-2018, 07:23 AM
Paul, that worked perfectly!
Thank you very much!
Doug