Opening Word maximized

philR

Active Member
Joined
Feb 25, 2002
Messages
257
OK, I have done the hard bit, now I am stuck on the easy bit! Using this code to open a word document, But I would like it to open with Word maximized, and the document at 100% zoom. Should be easy I know...

Dim myWord As Object
Set myWord = CreateObject("Word.Application")
myWord.Visible = True
myWord.Documents.Open FileName:="C:IntTrainTemplate.doc", ReadOnly:=True
With myWord
..do some stuff..
End With

Thanks
This message was edited by philR on 2002-10-02 04:58
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Ian Mac

MrExcel MVP
Joined
Feb 20, 2002
Messages
1,174
On 2002-10-02 04:57, philR wrote:
OK, I have done the hard bit, now I am stuck on the easy bit! Using this code to open a word document, But I would like it to open with Word maximized, and the document at 100% zoom. Should be easy I know...

Dim myWord As Object
Set myWord = CreateObject("Word.Application")
myWord.Visible = True
myWord.Documents.Open FileName:="C:IntTrainTemplate.doc", ReadOnly:=True
With myWord
..do some stuff..
End With

Thanks
This message was edited by philR on 2002-10-02 04:58

Try:

Sub Word()
Dim myWord As Object

Set myWord = CreateObject("Word.Application")
myWord.Visible = True
myWord.Documents.Open FileName:="C:IntTrainTemplate.doc", ReadOnly:=True
With myWord
.Application.WindowState = wdWindowStateMaximize
.ActiveWindow.ActivePane.View.Zoom.Percentage = 100
End With

Set myWord = Nothing

End Sub

Note: you will need to Set myWord = Nothing so Excel no longer has anything to do with Word. otherwise when you close Word it will still be memory.
 

philR

Active Member
Joined
Feb 25, 2002
Messages
257
Thanks.
The zoom thing is working, but the document still opens with Word taking up about 1/2 the screen. (I had already tried your idea) any others?
 

Ian Mac

MrExcel MVP
Joined
Feb 20, 2002
Messages
1,174
On 2002-10-02 05:57, philR wrote:
Thanks.
The zoom thing is working, but the document still opens with Word taking up about 1/2 the screen. (I had already tried your idea) any others?

the line:

.Application.WindowState = wdWindowStateMaximize

is working fine for me, if I comment it out I get a half screen as you describe?
 

philR

Active Member
Joined
Feb 25, 2002
Messages
257

ADVERTISEMENT

Wonder if it anything to do with it being a password protected document, which I am opening as read-only? Surely that shouldn't affect the application settings? Me puzzled.
 

Ian Mac

MrExcel MVP
Joined
Feb 20, 2002
Messages
1,174
On 2002-10-02 06:23, philR wrote:
Wonder if it anything to do with it being a password protected document, which I am opening as read-only? Surely that shouldn't affect the application settings? Me puzzled.

Could be??

Try:

myWord.Documents.Open FileName:="C:IntTrainTemplate.doc", Passworddocument:="YourPassword", ReadOnly:=True
 

philR

Active Member
Joined
Feb 25, 2002
Messages
257

ADVERTISEMENT

Still nothing.
 

Ian Mac

MrExcel MVP
Joined
Feb 20, 2002
Messages
1,174
On 2002-10-02 06:44, philR wrote:
Still nothing.

I really can't think of anything,
have you tried running it without loading the document, to see if it work like that?
 

philR

Active Member
Joined
Feb 25, 2002
Messages
257
Ha! Solved it. For some reason, it wouldn't accept wdwindowstatemaximize, but it works if I put 1 instead. Maybe it is because excel doesn't recognise it? I am using excel 97 - maybe that makes a difference. Anyway, thanks for your patience and help.

PhilR
 

Ian Mac

MrExcel MVP
Joined
Feb 20, 2002
Messages
1,174
On 2002-10-02 07:59, philR wrote:
Ha! Solved it. For some reason, it wouldn't accept wdwindowstatemaximize, but it works if I put 1 instead. Maybe it is because excel doesn't recognise it? I am using excel 97 - maybe that makes a difference. Anyway, thanks for your patience and help.

PhilR

A damned fool mistake for me to make,
only recently I was told to pass the value NOT the name, as the application will always pick up the value.

A*se! sorry, it was a gem of information i thought I'd remember (and should have).
oh well, glad to hear it works.
 

Forum statistics

Threads
1,144,117
Messages
5,722,581
Members
422,447
Latest member
knopp

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top