1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Word VBA Page Numbering turns Table borders on.

Discussion in 'Business Applications' started by Ripperdan, Apr 21, 2010.

Thread Status:
Not open for further replies.
  1. Ripperdan

    Ripperdan Thread Starter

    Joined:
    Oct 28, 2009
    Messages:
    64
    First Name:
    Danny
    In Word 2002, I have quite an extensive macro that inserts text, tables and graphics. Some of the tables are supposed to have their borders turned off.

    My beginning of the macro opens a new document, does the page setup and then adds page numbering.

    This is the code.:

    Documents.Add DocumentType:=wdNewBlankDocument

    ActiveWindow.View.Type = wdPrintView

    With ActiveDocument.PageSetup
    .Orientation = wdOrientPortrait
    .TopMargin = InchesToPoints(0.3)
    .BottomMargin = InchesToPoints(0.5)
    .LeftMargin = InchesToPoints(0.5)
    .RightMargin = InchesToPoints(0.5)
    .Gutter = InchesToPoints(0.5)
    .HeaderDistance = InchesToPoints(0)
    .FooterDistance = InchesToPoints(0.2)
    .PageWidth = InchesToPoints(8.5)
    .PageHeight = InchesToPoints(11)
    .MirrorMargins = True
    End With

    With ActiveDocument.Sections(1)
    .Footers(wdHeaderFooterPrimary).PageNumbers.Add _
    PageNumberAlignment:=wdAlignPageNumberCenter, _
    FirstPage:=True
    End With


    When I run the macro with the “ActiveDocument.Sections(1)” commented out, the tables show no borders like they are supposed to. If I Un-Comment the “ActiveDocument.Sections(1)” and run the macro, all the tables have their borders on. Anyone have an idea why?

    Actually, I would like to have the Odd page numbers on the right and the Even page numbers on the left but I had some trouble getting that to work correctly so I settled for having the page numbers in the center on all pages. If you could help me with the code to get the Odd/Even page numbering to work, I’d appreciate it.
     
  2. md2lgyk

    md2lgyk

    Joined:
    Jul 3, 2003
    Messages:
    1,068
    I know nothing about using Word macros so I'm sorry I can't help. But what you're doing seems an exceedingly complicated way to generate a new document. How often do you do it? Why don't you just set your document template to a layout of different odd and even page header and footer?
     
  3. Ripperdan

    Ripperdan Thread Starter

    Joined:
    Oct 28, 2009
    Messages:
    64
    First Name:
    Danny
    Thanks for responding.

    The macro mentioned is stored in a database type file and the information in that database is manipulated in a couple of different ways, requiring that it opens a new document to insert the manipulated information into. This will eventually be used by a number of people who don't have a clue what a word template is or where to save it. That being the case, I have to put in the code to do the page setup. Everything works as expected except the page setup stuff.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/918396

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice