+ Reply to Thread
Results 1 to 4 of 4

Why is objRange.ParagraphFormat.Align=1 applying to objRange and objRange1? Help me fix it

  1. #1
    Registered User
    Join Date
    05-17-2019
    Location
    Madison
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    11

    Why is objRange.ParagraphFormat.Align=1 applying to objRange and objRange1? Help me fix it

    I'm trying to apply a center align to ONLY the 'create header' section objRange. I managed to keep bold formatting within objRange, but for some reason objRange.ParagraphFormat.Alignment = 1 is also centering the text in the table. I realize I'm probably making a pretty basic mistake but I'm pretty new to coding and don't understand what I'm doing wrong. I am generating the word report from an excel macro so please let me know if this is in the wrong section.

    Please Login or Register  to view this content.
    Last edited by Sprong; 04-15-2020 at 02:23 PM.

  2. #2
    Forum Guru macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,497

    Re: Why is objRange.ParagraphFormat.Align=1 applying to objRange and objRange1? Help me fi

    That's because you've pointed both to the same range. Your code could also be greatly simplified:
    Please Login or Register  to view this content.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    05-17-2019
    Location
    Madison
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    11

    Re: Why is objRange.ParagraphFormat.Align=1 applying to objRange and objRange1? Help me fi

    Thank you @macropod for this solution. I know the code was far from simplified but I was still just trying to piece it together to do what I needed it to. If I wanted to have another header section immediately below the table, how would I need to alter the code you've provided?

    Please Login or Register  to view this content.
    I've tried copying it but it overwrites everything. I'm trying to learn how to create distinct ranges of text; I'm unsure how to change this to do that.
    Last edited by Sprong; 04-15-2020 at 11:56 AM.

  4. #4
    Forum Guru macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,497

    Re: Why is objRange.ParagraphFormat.Align=1 applying to objRange and objRange1? Help me fi

    What would be in that 'another header section immediately below the table'?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA excel to word insert footer (Text - Left align) & (Page number - Right align)
    By Richavlaues in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2017, 06:22 PM
  2. Replies: 0
    Last Post: 08-10-2016, 12:34 PM
  3. Align To The Right
    By Bob2Dyaln in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-30-2007, 09:00 AM
  4. right align columns
    By stermann in forum Excel General
    Replies: 2
    Last Post: 08-15-2007, 06:05 AM
  5. [SOLVED] How do I align the sheet?
    By Guy Cohen in forum Excel General
    Replies: 1
    Last Post: 02-07-2006, 06:01 AM
  6. Left align '$' and right align numbers?
    By skeetley in forum Excel General
    Replies: 1
    Last Post: 10-21-2005, 03:12 AM
  7. [SOLVED] What is short-Cut forleft align and Right align?
    By Sandy in forum Excel General
    Replies: 1
    Last Post: 02-24-2005, 09:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1