I'm trying to create a macro to change my margins, make a document have 2
cols., and insert a page number at the end of the page using a keybord
command.
No matter how I try or which order I try these steps, I get the debug error
5941.
I don't know what that means, I don't know what i've done wrong.
Can anybody help?
Thanks,
Gabe
Suzanne S. Barnhill - 13 May 2008 04:01 GMT
Can you explain why you're using a macro instead of a template for this?

Signature
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
> I'm trying to create a macro to change my margins, make a document have 2
> cols., and insert a page number at the end of the page using a keybord
[quoted text clipped - 9 lines]
>
> Gabe
Gabe - 13 May 2008 23:02 GMT
Suzanne:
That's a good question, BUT I don't know what a template is.
I do intend to find out.
I have been using Word/97 and it was very easy to record a Macro to do what
I've been trying to do in Word/2007.
I guess my statment should have been I'm trying to RECORD a Macro.
Thanks,
Gabe
> Can you explain why you're using a macro instead of a template for this?
>
[quoted text clipped - 11 lines]
> >
> > Gabe
Suzanne S. Barnhill - 13 May 2008 23:12 GMT
The reason I asked is that everything you're trying to do with a macro can
be achieved much more simply in a template; see
http://word.mvps.org/FAQs/Customization/CreateATemplatePart1.htm.
When you don't choose any other template, your documents are based on
Normal.dot (or Normal.dotm in Word 2007), but you can have as many templates
as you like, and it makes sense to create a template for any specific type
of formatting you use frequently. If you use some different settings for
*all* documents, you may want to customize Normal.dot instead (see
http://word.mvps.org/FAQs/Customization/CustomizeNormalTemplate.htm), but
adding page numbers or columns to Normal.dot is not recommended.

Signature
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
> Suzanne:
> That's a good question, BUT I don't know what a template is.
[quoted text clipped - 24 lines]
>> >
>> > Gabe
StevenM - 13 May 2008 12:57 GMT
Assuming you need more than one page setup, you might try modifing the
following to your needs. If you only need one page setup, you should create a
new template.
Sub TestPageSetup()
Dim nColumns As Long
Dim pColWidth As Single
Dim pColGutter As Single
Dim pTop As Single
Dim pBottom As Single
Dim pLeft As Single
Dim pRight As Single
Dim pWidth As Single
Dim oRange As Range
Dim footerRange As Range
pTop = 6
pBottom = 6
pLeft = 6.5
pRight = 6.5
pColGutter = 3
nColumns = 2
pColWidth = (51 - (pColGutter + pRight + pLeft)) / nColumns
Set oRange = ActiveDocument.Range(Start:=ActiveDocument.Range.Start,
End:=ActiveDocument.Range.End)
With oRange.PageSetup
.TopMargin = PicasToPoints(pTop)
.BottomMargin = PicasToPoints(pBottom)
.LeftMargin = PicasToPoints(pLeft)
.RightMargin = PicasToPoints(pRight)
End With
With oRange.PageSetup.TextColumns
.SetCount NumColumns:=nColumns
.EvenlySpaced = True
.LineBetween = False
.Width = PicasToPoints(pColWidth)
.Spacing = PicasToPoints(pColGutter)
End With
Set footerRange = oRange.Sections(1).Footers(wdHeaderFooterPrimary).Range
With footerRange
.Delete
With .ParagraphFormat.TabStops
.ClearAll
pWidth = 51 - (pLeft + pRight)
.Add Position:=PicasToPoints(pWidth / 2),
Alignment:=wdAlignTabCenter
.Add Position:=PicasToPoints(pWidth), Alignment:=wdAlignTabRight
End With
.InsertAfter vbTab & vbTab & "Page "
.MoveEnd unit:=wdCharacter, Count:=1
.Collapse wdCollapseEnd
oRange.Fields.Add Range:=footerRange, Type:=wdFieldPage
.MoveEnd unit:=wdCharacter, Count:=1
.Collapse wdCollapseEnd
.InsertAfter vbCr
End With
End Sub
> I'm trying to create a macro to change my margins, make a document have 2
> cols., and insert a page number at the end of the page using a keybord
[quoted text clipped - 8 lines]
>
> Gabe
Gabe - 13 May 2008 22:56 GMT
I guess I should have said I'm trying to RECORD a macro, I don't know
anything about the language you're using, maybe I should. I'll look into
creating a Template.
By the way someone sent me an email with a website that they said would
answer my question. The website was blank.
Thanks,
Gabe
> I'm trying to create a macro to change my margins, make a document have 2
> cols., and insert a page number at the end of the page using a keybord
[quoted text clipped - 8 lines]
>
> Gabe
Graham Mayor - 14 May 2008 06:06 GMT
http://www.gmayor.com/installing_macro.htm will explain what to do with vba
listings.

Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> I guess I should have said I'm trying to RECORD a macro, I don't know
> anything about the language you're using, maybe I should. I'll look
[quoted text clipped - 19 lines]
>>
>> Gabe
StevenM - 14 May 2008 12:58 GMT
There is also an old-fashioned resource, one which some of us old-timers
still like to use, it is called a “book.” It might be hard for some of you
youngsters to imagine, but some of us old-timers read information on paper as
well as information on a screen. And I’m not talking about a printout, but
something more than a handful of loose pages. A “book” is actually pages of
printed paper sewn (or glued) together, with a cloth (or cardboard) cover. I
would recommend you finding a book on Microsoft Word, they will have chapters
on creating a template, or working with macros. Such books usually go into
more detail than the (otherwise wonder) tutorials you find on the Internet.
You can find books for sale (new and used) on the Internet, or you can try
locating a place which warehouses and sells them, it is called a “bookstore.”
Just ask any old geezer where one might be, they will be able to give you
directions.
> I guess I should have said I'm trying to RECORD a macro, I don't know
> anything about the language you're using, maybe I should. I'll look into
[quoted text clipped - 19 lines]
> >
> > Gabe