Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
John... Visio MVP John... Visio MVP is offline
external usenet poster
 
Posts: 33
Default Looking for a suggestion on how to handle a header

Does anyone have a suggestion for including two pieces of information in a
header AFTER massaging? I can get the information in the header using
StyleRef, but I would like to truncate the combined string if it is longer
than a certain length and add "..." to the end.


I have an update macro that builds tables, so I can easily add extra code to
the routine to do the combining and massaging of the information, I just
need an idea of where the massaged information can be placed so it can be
picked up by the header.

John... Visio MVP

  #2   Report Post  
Posted to microsoft.public.word.newusers
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Looking for a suggestion on how to handle a header

Hi John,

You could put the massaged info into a custom Document Property, and use a DOCPROPERTY field in the header to link to it.

--
Cheers
macropod
[Microsoft MVP - Word]


"John... Visio MVP" wrote in message ...
Does anyone have a suggestion for including two pieces of information in a
header AFTER massaging? I can get the information in the header using
StyleRef, but I would like to truncate the combined string if it is longer
than a certain length and add "..." to the end.


I have an update macro that builds tables, so I can easily add extra code to
the routine to do the combining and massaging of the information, I just
need an idea of where the massaged information can be placed so it can be
picked up by the header.

John... Visio MVP

  #3   Report Post  
Posted to microsoft.public.word.newusers
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 264
Default Looking for a suggestion on how to handle a header

On Jul 17, 3:30*pm, "John... Visio MVP"
wrote:
Does anyone have a suggestion for including two pieces of information in a
header AFTER massaging? I can get the information in the header using
StyleRef, but I would like to truncate the combined string if it is longer
than a certain length and add "..." to the end.

I have an update macro that builds tables, so I can easily add extra code to
the routine to do the combining and massaging of the information, I just
need an idea of where the massaged information can be placed so it can be
picked up by the header.

John... Visio MVP


John,

Perhaps you could use a DocVariable in the header.

{DocVariable HeaderText}

In this example code, the text in the document is bound by a bookmark
"HeaderText"

Sub ScratchMacro()
Dim pStr As String
Dim oSect As Section
Dim i As Long
pStr = ActiveDocument.Bookmarks("HeaderText").Range.Text
If Len(pStr) 25 Then
ActiveDocument.Variables("HeaderText").Value = Left(pStr, 25) &
" ..."
Else
ActiveDocument.Variables("HeaderText").Value = pStr
End If
For Each oSect In ActiveDocument.Sections
For i = 1 To 3
oSect.Headers(i).Range.Fields.Update
Next i
Next oSect
End Sub





  #4   Report Post  
Posted to microsoft.public.word.newusers
John... Visio MVP John... Visio MVP is offline
external usenet poster
 
Posts: 33
Default Looking for a suggestion on how to handle a header

I had thought of that, but this will happen several times in the document.
So even if I create a Document Property for each pair, I still need to find
someway of referencing each one in the header.

John... Visio MVP

"macropod" wrote in message
...
Hi John,

You could put the massaged info into a custom Document Property, and use a
DOCPROPERTY field in the header to link to it.

--
Cheers
macropod
[Microsoft MVP - Word]


"John... Visio MVP" wrote in message
...
Does anyone have a suggestion for including two pieces of information in
a header AFTER massaging? I can get the information in the header using
StyleRef, but I would like to truncate the combined string if it is
longer than a certain length and add "..." to the end.


I have an update macro that builds tables, so I can easily add extra code
to the routine to do the combining and massaging of the information, I
just need an idea of where the massaged information can be placed so it
can be picked up by the header.

John... Visio MVP



  #5   Report Post  
Posted to microsoft.public.word.newusers
John... Visio MVP John... Visio MVP is offline
external usenet poster
 
Posts: 33
Default Looking for a suggestion on how to handle a header

"Greg Maxey" wrote in message
...
On Jul 17, 3:30 pm, "John... Visio MVP"
wrote:
Does anyone have a suggestion for including two pieces of information in a
header AFTER massaging? I can get the information in the header using
StyleRef, but I would like to truncate the combined string if it is longer
than a certain length and add "..." to the end.

I have an update macro that builds tables, so I can easily add extra code
to
the routine to do the combining and massaging of the information, I just
need an idea of where the massaged information can be placed so it can be
picked up by the header.

John... Visio MVP


John,

Perhaps you could use a DocVariable in the header.

{DocVariable HeaderText}

In this example code, the text in the document is bound by a bookmark
"HeaderText"

Sub ScratchMacro()
Dim pStr As String
Dim oSect As Section
Dim i As Long
pStr = ActiveDocument.Bookmarks("HeaderText").Range.Text
If Len(pStr) 25 Then
ActiveDocument.Variables("HeaderText").Value = Left(pStr, 25) &
" ..."
Else
ActiveDocument.Variables("HeaderText").Value = pStr
End If
For Each oSect In ActiveDocument.Sections
For i = 1 To 3
oSect.Headers(i).Range.Fields.Update
Next i
Next oSect
End Sub

Am I missing something? You take the text at the bookmark HeaderText,
massage it and store it in a Variable called HeaderText. Then you loop
through the first three sections updating the headers. Why update the
headers?

I have a version that works for a single group and the group information
appears in the header. I need it to work for several groups with a different
header for each group. A simple StyleRef will work, but if I need to massage
the information, I need a location to store the information. One possibility
would be to use a style with hidden text.

John... Visio MVP








  #6   Report Post  
Posted to microsoft.public.word.newusers
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Looking for a suggestion on how to handle a header

John,

Am I missing something? You take the text at the bookmark HeaderText,
massage it and store it in a Variable called HeaderText. Then you loop
through the first three sections updating the headers. Why update the
headers?


You put a "field" {DocVarialbe HeaderText} in the header. You have your
text somewhere (I used a bookmark as an example). You "massage" or truncate
the text and store it in a document varialbe. You are not looping through
the first three sections. You are looping through the 3 header types in
every section in order to update the field.


John... Visio MVP wrote:
"Greg Maxey" wrote in message
...
On Jul 17, 3:30 pm, "John... Visio MVP"
wrote:
Does anyone have a suggestion for including two pieces of
information in a header AFTER massaging? I can get the information
in the header using StyleRef, but I would like to truncate the
combined string if it is longer than a certain length and add "..."
to the end. I have an update macro that builds tables, so I can easily
add extra
code to
the routine to do the combining and massaging of the information, I
just need an idea of where the massaged information can be placed so
it can be picked up by the header.

John... Visio MVP


John,

Perhaps you could use a DocVariable in the header.

{DocVariable HeaderText}

In this example code, the text in the document is bound by a bookmark
"HeaderText"

Sub ScratchMacro()
Dim pStr As String
Dim oSect As Section
Dim i As Long
pStr = ActiveDocument.Bookmarks("HeaderText").Range.Text
If Len(pStr) 25 Then
ActiveDocument.Variables("HeaderText").Value = Left(pStr, 25) &
" ..."
Else
ActiveDocument.Variables("HeaderText").Value = pStr
End If
For Each oSect In ActiveDocument.Sections
For i = 1 To 3
oSect.Headers(i).Range.Fields.Update
Next i
Next oSect
End Sub

Am I missing something? You take the text at the bookmark HeaderText,
massage it and store it in a Variable called HeaderText. Then you loop
through the first three sections updating the headers. Why update the
headers?

I have a version that works for a single group and the group
information appears in the header. I need it to work for several
groups with a different header for each group. A simple StyleRef will
work, but if I need to massage the information, I need a location to
store the information. One possibility would be to use a style with
hidden text.
John... Visio MVP


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org



  #7   Report Post  
Posted to microsoft.public.word.newusers
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Looking for a suggestion on how to handle a header

Hi John,

You can have multiple custom document properties, if need be. It's then a simple matter of referring to the correct one with the
field.

--
Cheers
macropod
[Microsoft MVP - Word]


"John... Visio MVP" wrote in message ...
I had thought of that, but this will happen several times in the document. So even if I create a Document Property for each pair, I
still need to find someway of referencing each one in the header.

John... Visio MVP

"macropod" wrote in message ...
Hi John,

You could put the massaged info into a custom Document Property, and use a DOCPROPERTY field in the header to link to it.

--
Cheers
macropod
[Microsoft MVP - Word]


"John... Visio MVP" wrote in message ...
Does anyone have a suggestion for including two pieces of information in a header AFTER massaging? I can get the information in
the header using StyleRef, but I would like to truncate the combined string if it is longer than a certain length and add "..."
to the end.


I have an update macro that builds tables, so I can easily add extra code to the routine to do the combining and massaging of
the information, I just need an idea of where the massaged information can be placed so it can be picked up by the header.

John... Visio MVP




  #8   Report Post  
Posted to microsoft.public.word.newusers
John... Visio MVP John... Visio MVP is offline
external usenet poster
 
Posts: 33
Default Looking for a suggestion on how to handle a header

"Greg Maxey" wrote in message
...
John,

Am I missing something? You take the text at the bookmark HeaderText,
massage it and store it in a Variable called HeaderText. Then you loop
through the first three sections updating the headers. Why update the
headers?


You put a "field" {DocVarialbe HeaderText} in the header. You have your
text somewhere (I used a bookmark as an example). You "massage" or
truncate the text and store it in a document varialbe. You are not
looping through the first three sections. You are looping through the 3
header types in every section in order to update the field.


Thanks Greg.

That makes sense. The use of "1 to 3" threw me. wdHeaderFooterFirstPage,
wdHeaderFooterPrimary or wdHeaderFooterEvenPages is what I have seen in the
past, but the use of "1 to 3" is more efficient.

The other part that had me confused is that there will only be ONE
DcVariable in the document, so only one variation of the header.

What I am looking for is something like a Docment with a headers that says
"Test VW - Performance",
"Test VW - Economy",
"Test BMW - Some long winded test that gets truncated..."

I am trying to avoid using the word Section because I would prefer not to do
it with Section breaks, but each grouping starts on a new page and has a
line with a special style for "Vehicle" that would contain VW or BMW or...
and another line that would contain a special style for the test type.

I am going to play with StyleRef to see if I can do it with just StyleRef.

John... Visio MVP


John... Visio MVP wrote:
"Greg Maxey" wrote in message
...
On Jul 17, 3:30 pm, "John... Visio MVP"
wrote:
Does anyone have a suggestion for including two pieces of
information in a header AFTER massaging? I can get the information
in the header using StyleRef, but I would like to truncate the
combined string if it is longer than a certain length and add "..."
to the end. I have an update macro that builds tables, so I can easily
add extra
code to
the routine to do the combining and massaging of the information, I
just need an idea of where the massaged information can be placed so
it can be picked up by the header.

John... Visio MVP


John,

Perhaps you could use a DocVariable in the header.

{DocVariable HeaderText}

In this example code, the text in the document is bound by a bookmark
"HeaderText"

Sub ScratchMacro()
Dim pStr As String
Dim oSect As Section
Dim i As Long
pStr = ActiveDocument.Bookmarks("HeaderText").Range.Text
If Len(pStr) 25 Then
ActiveDocument.Variables("HeaderText").Value = Left(pStr, 25) &
" ..."
Else
ActiveDocument.Variables("HeaderText").Value = pStr
End If
For Each oSect In ActiveDocument.Sections
For i = 1 To 3
oSect.Headers(i).Range.Fields.Update
Next i
Next oSect
End Sub

Am I missing something? You take the text at the bookmark HeaderText,
massage it and store it in a Variable called HeaderText. Then you loop
through the first three sections updating the headers. Why update the
headers?

I have a version that works for a single group and the group
information appears in the header. I need it to work for several
groups with a different header for each group. A simple StyleRef will
work, but if I need to massage the information, I need a location to
store the information. One possibility would be to use a style with
hidden text.
John... Visio MVP


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org





  #9   Report Post  
Posted to microsoft.public.word.newusers
John... Visio MVP John... Visio MVP is offline
external usenet poster
 
Posts: 33
Default Looking for a suggestion on how to handle a header

Thanks macropod,

I still seem to be missing something. How can you have a single header that
adjusts to different document properties? With StyleRef, the content
displayed changes with each new use of a specific style.

John... Visio MVP
"macropod" wrote in message
...
Hi John,

You can have multiple custom document properties, if need be. It's then a
simple matter of referring to the correct one with the field.

--
Cheers
macropod
[Microsoft MVP - Word]


"John... Visio MVP" wrote in message
...
I had thought of that, but this will happen several times in the document.
So even if I create a Document Property for each pair, I still need to
find someway of referencing each one in the header.

John... Visio MVP

"macropod" wrote in message
...
Hi John,

You could put the massaged info into a custom Document Property, and use
a DOCPROPERTY field in the header to link to it.

--
Cheers
macropod
[Microsoft MVP - Word]


"John... Visio MVP" wrote in message
...
Does anyone have a suggestion for including two pieces of information
in a header AFTER massaging? I can get the information in the header
using StyleRef, but I would like to truncate the combined string if it
is longer than a certain length and add "..." to the end.


I have an update macro that builds tables, so I can easily add extra
code to the routine to do the combining and massaging of the
information, I just need an idea of where the massaged information can
be placed so it can be picked up by the header.

John... Visio MVP






  #10   Report Post  
Posted to microsoft.public.word.newusers
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Looking for a suggestion on how to handle a header

Hi John,

For that, you'd probably need a combination of Section breaks and/or different first page/add-even page layouts. A solution bsed on
IF fields might also be possible.

--
Cheers
macropod
[Microsoft MVP - Word]


"John... Visio MVP" wrote in message ...
Thanks macropod,

I still seem to be missing something. How can you have a single header that adjusts to different document properties? With
StyleRef, the content displayed changes with each new use of a specific style.

John... Visio MVP
"macropod" wrote in message ...
Hi John,

You can have multiple custom document properties, if need be. It's then a simple matter of referring to the correct one with the
field.

--
Cheers
macropod
[Microsoft MVP - Word]


"John... Visio MVP" wrote in message ...
I had thought of that, but this will happen several times in the document. So even if I create a Document Property for each pair,
I still need to find someway of referencing each one in the header.

John... Visio MVP

"macropod" wrote in message ...
Hi John,

You could put the massaged info into a custom Document Property, and use a DOCPROPERTY field in the header to link to it.

--
Cheers
macropod
[Microsoft MVP - Word]


"John... Visio MVP" wrote in message ...
Does anyone have a suggestion for including two pieces of information in a header AFTER massaging? I can get the information
in the header using StyleRef, but I would like to truncate the combined string if it is longer than a certain length and add
"..." to the end.


I have an update macro that builds tables, so I can easily add extra code to the routine to do the combining and massaging of
the information, I just need an idea of where the massaged information can be placed so it can be picked up by the header.

John... Visio MVP








  #11   Report Post  
Posted to microsoft.public.word.newusers
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Looking for a suggestion on how to handle a header

Aside from adding the ellipsis, you can accomplish the truncated text with
StyleRef. See http://sbarnhill.mvps.org/WordFAQs/S...PartialHeading

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"John... Visio MVP" wrote in message
...
"Greg Maxey" wrote in message
...
John,

Am I missing something? You take the text at the bookmark HeaderText,
massage it and store it in a Variable called HeaderText. Then you loop
through the first three sections updating the headers. Why update the
headers?


You put a "field" {DocVarialbe HeaderText} in the header. You have your
text somewhere (I used a bookmark as an example). You "massage" or
truncate the text and store it in a document varialbe. You are not
looping through the first three sections. You are looping through the 3
header types in every section in order to update the field.


Thanks Greg.

That makes sense. The use of "1 to 3" threw me. wdHeaderFooterFirstPage,
wdHeaderFooterPrimary or wdHeaderFooterEvenPages is what I have seen in
the past, but the use of "1 to 3" is more efficient.

The other part that had me confused is that there will only be ONE
DcVariable in the document, so only one variation of the header.

What I am looking for is something like a Docment with a headers that says
"Test VW - Performance",
"Test VW - Economy",
"Test BMW - Some long winded test that gets truncated..."

I am trying to avoid using the word Section because I would prefer not to
do it with Section breaks, but each grouping starts on a new page and has
a line with a special style for "Vehicle" that would contain VW or BMW
or... and another line that would contain a special style for the test
type.

I am going to play with StyleRef to see if I can do it with just StyleRef.

John... Visio MVP


John... Visio MVP wrote:
"Greg Maxey" wrote in message
...
On Jul 17, 3:30 pm, "John... Visio MVP"
wrote:
Does anyone have a suggestion for including two pieces of
information in a header AFTER massaging? I can get the information
in the header using StyleRef, but I would like to truncate the
combined string if it is longer than a certain length and add "..."
to the end. I have an update macro that builds tables, so I can easily
add extra
code to
the routine to do the combining and massaging of the information, I
just need an idea of where the massaged information can be placed so
it can be picked up by the header.

John... Visio MVP

John,

Perhaps you could use a DocVariable in the header.

{DocVariable HeaderText}

In this example code, the text in the document is bound by a bookmark
"HeaderText"

Sub ScratchMacro()
Dim pStr As String
Dim oSect As Section
Dim i As Long
pStr = ActiveDocument.Bookmarks("HeaderText").Range.Text
If Len(pStr) 25 Then
ActiveDocument.Variables("HeaderText").Value = Left(pStr, 25) &
" ..."
Else
ActiveDocument.Variables("HeaderText").Value = pStr
End If
For Each oSect In ActiveDocument.Sections
For i = 1 To 3
oSect.Headers(i).Range.Fields.Update
Next i
Next oSect
End Sub

Am I missing something? You take the text at the bookmark HeaderText,
massage it and store it in a Variable called HeaderText. Then you loop
through the first three sections updating the headers. Why update the
headers?

I have a version that works for a single group and the group
information appears in the header. I need it to work for several
groups with a different header for each group. A simple StyleRef will
work, but if I need to massage the information, I need a location to
store the information. One possibility would be to use a style with
hidden text.
John... Visio MVP


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org






Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i handle an image? Mimi Microsoft Word Help 1 November 9th 06 02:15 PM
Suggestion for speeding up adjustment of header/footer jochsner Page Layout 0 September 1st 06 04:40 PM
what is a handle Melissa Microsoft Word Help 3 August 16th 06 06:35 AM
Looking for best way to handle data entry JM Microsoft Word Help 8 April 8th 06 03:30 AM
handle many figures mike Page Layout 1 January 27th 06 10:28 PM


All times are GMT +1. The time now is 02:34 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"