Can word remember the window size I like?

J

John McGhie

Kevs, Kevs, Kevs...

You actually have to read this stuff you know :) You have two threads
going in two different newsgroups. I sent you the whole thing, then I sent
you a replacement for one of the four macros.

Here it is again: This time, delete everything you have in your Normal
Template, and then paste this in, in its place:

Option Explicit

Sub AutoOpen()
Call SetWindowSize
End Sub
Sub AutoNew()
Call SetWindowSize
End Sub

Sub SetWindowSize()
'
' SetWindowSize Macro
'
'
Dim aDoc As Document
Dim aWindow As Window

Set aDoc = ActiveDocument
Set aWindow = aDoc.ActiveWindow

With aWindow
.WindowState = wdWindowStateNormal
.Height = (Application.UsableHeight * 1)
.Width = (Application.UsableWidth * 0.5)
.Left = ((Application.UsableWidth - .Width) / 2)
.View.Zoom.Percentage = 125
End With

End Sub

Remember you have to paste into TextEdit first, and "Make Plain Text". Then
copy from TextEdit and paste into the VBA Editor.

Note: I have condensed this: there are now THREE macros, not four. Each
line beginning with "Sub" marks the beginning of a macro (a "subroutine").
Each line that contains only "End Sub" marks the end of a macro.

When you paste this in, if any parts turn red, tell me what they are: that's
a compile error and it won't run if that happens.

Cheers

John, done what? I don't even recall the first there macros you are talking
about. .. maybe you can unify it. But again, I pasted that one thing in did
not work, so deleted it.
John,
also, in normal document, I got it to stick at 125%, but it will not center,
even though I save it centered. It still launches upper left screen upon
launch of app.

--

The email below is my business email -- Please do not email me about forum
matters unless I ask you to; or unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:[email protected]
 
K

kevs12

JOHN,
I pasted it text to macro, then what?
I don't even know how to exit that.
there is no record button to stop.
Everything just hangs there, how do I know that macro is done?
 
K

kevs12

Ok- I got it deleted using organzier, but had to delete my only two macros I had. This why I hate macro, if you don't know what your are doing it's very dangerous stuff. I have no idea what I'm doing.
I'm painting by numbers.
 
K

kevs12

"delete everything in normal template -- paste this is?"

You mean open up normal and paste macro text in there as well?
 
J

John McGhie

When you are done: close the VBA editor by clicking the blue W icon at the
top left of the VBA Editor window.


JOHN,
I pasted it text to macro, then what?
I don't even know how to exit that.
there is no record button to stop.
Everything just hangs there, how do I know that macro is done?

--

The email below is my business email -- Please do not email me about forum
matters unless I ask you to; or unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:[email protected]
 
J

John McGhie

You CHANGED THE NAME :)

This is a structure of macros that call each other by name. If you change
the name of the macro, it cannot work.

There are three macros I sent in the bundle. They need to be pasted as a
single piece of text.

You must not change any of the names.

The names are hard-coded in the top line of each macro.

Try this:

1) Hit Option + F11 to open the VBA Editor. When it opens, you should see
a three-pane view. The top left pane should be named "Projects". That
lists all of the templates and documents that are open.

2) The Normal project (which is the Normal Template) should be expanded. If
it isn't, click the grey disclosure triangle to the left of the name to drop
it down.

There will be a project below named "Project (Document 1)". That's the open
document: stay out of there. We never put macros in there.

3) Chances are in your template you have only one module, and it is
probably named "NewMacros". I can't tell: you could have changed this, but
you probably haven't. If you cannot see any modules listed, drop down the
disclosure triangle on "Modules" so you can.

4) If it is called NewMacros, double-click it to open it. A pane will
appear to the right headed "Normal ‹ NewMacros (Code)."

See the screen shot here:
http://public.jgmcghie.fastmail.com.au/VBA Editor

Now, you can see the three macros in the screen shot? They are named "Sub
AutoOpen()", "Sub AutoNew()" and "Sub SetWindowSize".

Paste the text I sent so that it looks exactly like the screen shot.

Make sure you have no other macros named "AutoOpen", "AutoNew", or
"SetWindowSize". (If you have, you will get a warning about "Multiple names
in the same context" when you try to compile.)

If any lines turn RED, there is a problem with your pasting. You may have
forgotten to "Make Plain Text". Tell me which ones they are, if that is the
case, and I will help you fix them.

Let's check if everything is OK: On the Debug menu, choose the "Compile
Normal" entry. If all is going well, it should appear as if nothing
happened. If there are any errors anywhere in your Normal Template VBA, the
first error found will be highlighted in yellow, and a message will appear
telling you what is wrong.

Assuming no errors, close the VBA Editor by clicking the blue W you see at
the top left of the screenshot.

That's all you have to do: it's working now :)

It would be good if you were to stop telling yourself that this is
"Difficult" or "Dangerous". It isn't. But you do have to avoid the
temptation to make "little improvements" along the way.

Somehow, you wound up trying to do this from the Macros dialog, not the VBA
Editor. Not a good place to start: it makes things very difficult :)

And now you know that you cannot change names in a "set" of macros. You
also know that you cannot change the names of the "Auto..." series macros at
all: or they won't work.

Hope this helps


I deleted all sub macros but the title one I made reszie I can't delete now.
greyed out, delete button, why

http://tinypic.com/r/2ajnhiv/6

--

The email below is my business email -- Please do not email me about forum
matters unless I ask you to; or unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:[email protected]
 

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