How to do it in MS Word?

Re: align text left and align text right: on the same line by Jay

Jay
Sat Aug 20 10:30:56 CDT 2005

On 20 Aug 2005 07:11:24 -0700, kellrobinson@billburg.com wrote:

>How to do it in MS Word?

Set a right-aligned tab stop at the right margin. After entering the
left-aligned text, press Tab and then enter the right-aligned text.

The styles named Header and Footer already have the desired tab stop,
as well as one at the center of the line. You can define your own
style with a right-aligned tab and apply it wherever you want.

BTW, this question is off-topic in a VBA newsgroup unless you're
asking how to do it in a macro. It would be more appropriate to post
it in the microsoft.public.word.pagelayout group.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

Re: align text left and align text right: on the same line by Thirsty4knowledge

Thirsty4knowledge
Tue Aug 23 10:05:02 CDT 2005

Jay -

I am trying to do this with VBA. What I really need is to access ONLY the
middle "section" (I know this is not the correct use of my vocab) in the
header and footer. For example, I'm trying to get this done:

##### (TAB) MyString (TAB) ####

Where the pound signs are something anybody can manually enter, the (TAB) is
the seperating tabstop (making the header/footer have a left alligned section
of text, a center alligned section of text, and a right allighned section of
text). MyString is a variable in the VBA code.

Currently, all I can think of is count the total characters in the header,
then divide it by two (hoping that will land me in the middle) and selecting
the word that's associated with that character location, and changing it.
This really is way too buggy, and I know it's not the proper way to do
things! If you know of a way that I can access only the center section of a
header or footer, I'd greatly appreciate it... thanks!

Dereck

"Jay Freedman" wrote:

> On 20 Aug 2005 07:11:24 -0700, kellrobinson@billburg.com wrote:
>
> >How to do it in MS Word?
>
> Set a right-aligned tab stop at the right margin. After entering the
> left-aligned text, press Tab and then enter the right-aligned text.
>
> The styles named Header and Footer already have the desired tab stop,
> as well as one at the center of the line. You can define your own
> style with a right-aligned tab and apply it wherever you want.
>
> BTW, this question is off-topic in a VBA newsgroup unless you're
> asking how to do it in a macro. It would be more appropriate to post
> it in the microsoft.public.word.pagelayout group.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
>

Re: align text left and align text right: on the same line by Jay

Jay
Tue Aug 23 11:01:03 CDT 2005

Hi Dereck,

I'll assume you know how to assign a range to the correct header or footer,
dealing with the issues of different first page, different odd and even, and
multiple sections, so this example will just show the first-section main
footer being modified.

There are a couple of ways of dealing with this, but I think it's simplest
to just look for the tabs and adjust the range's ends to exclude the parts
you don't want to modify.

Sub Example()
Dim oRg As Range

Set oRg = ActiveDocument.Sections(1).Footers( _
wdHeaderFooterPrimary).Range

With oRg
If InStr(.Text, vbTab) > 0 Then
' There is at least one tab character, so
' move the range's start to the character
' after that tab.
.MoveStartUntil vbTab, wdForward
.MoveStart wdCharacter, 1

If InStr(.Text, vbTab) > 0 Then
' There is at least one more tab character,
' so move the range's end to the character
' before that tab.
.MoveEndUntil vbTab, wdBackward
.MoveEnd wdCharacter, -1
End If
End If

' Exclude the paragraph mark if range's end is
' at end of footer.
If .Characters.Last = vbCr Then
.MoveEnd wdCharacter, -1
End If

.Text = .Text & " altered"
.Font.Color = wdColorRed
End With

Set oRg = Nothing
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

Thirsty_4_knowledge wrote:
> Jay -
>
> I am trying to do this with VBA. What I really need is to access
> ONLY the middle "section" (I know this is not the correct use of my
> vocab) in the header and footer. For example, I'm trying to get this
> done:
>
> ##### (TAB) MyString (TAB) ####
>
> Where the pound signs are something anybody can manually enter, the
> (TAB) is the seperating tabstop (making the header/footer have a left
> alligned section of text, a center alligned section of text, and a
> right allighned section of text). MyString is a variable in the VBA
> code.
>
> Currently, all I can think of is count the total characters in the
> header, then divide it by two (hoping that will land me in the
> middle) and selecting the word that's associated with that character
> location, and changing it. This really is way too buggy, and I know
> it's not the proper way to do things! If you know of a way that I
> can access only the center section of a header or footer, I'd greatly
> appreciate it... thanks!
>
> Dereck
>
> "Jay Freedman" wrote:
>
>> On 20 Aug 2005 07:11:24 -0700, kellrobinson@billburg.com wrote:
>>
>>> How to do it in MS Word?
>>
>> Set a right-aligned tab stop at the right margin. After entering the
>> left-aligned text, press Tab and then enter the right-aligned text.
>>
>> The styles named Header and Footer already have the desired tab stop,
>> as well as one at the center of the line. You can define your own
>> style with a right-aligned tab and apply it wherever you want.
>>
>> BTW, this question is off-topic in a VBA newsgroup unless you're
>> asking how to do it in a macro. It would be more appropriate to post
>> it in the microsoft.public.word.pagelayout group.
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org