Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do i handle an image? | Microsoft Word Help | |||
Suggestion for speeding up adjustment of header/footer | Page Layout | |||
what is a handle | Microsoft Word Help | |||
Looking for best way to handle data entry | Microsoft Word Help | |||
handle many figures | Page Layout |