hello everyone
I write news scripts in MS Word and I need my wordcount of every page
somewhere, preferrably on teh header.
Is there a way I could achieve this.
If the info could be updated everytime I save would be great.
Hope some one could help.

thanx
ahmed

Re: put wordcount for each page on page header automatically by Jezebel

Jezebel
Fri Aug 04 05:19:48 CDT 2006

No, there's no easy way to do this.

Why do you care how many words are on your page?



"FotoArt" <FotoArt@discussions.microsoft.com> wrote in message
news:0DC47E05-B0F3-496A-9D81-CE710D2DF5BE@microsoft.com...
> hello everyone
> I write news scripts in MS Word and I need my wordcount of every page
> somewhere, preferrably on teh header.
> Is there a way I could achieve this.
> If the info could be updated everytime I save would be great.
> Hope some one could help.
>
> thanx
> ahmed



Re: put wordcount for each page on page header automatically by FotoArt

FotoArt
Fri Aug 04 12:33:02 CDT 2006

Hello Jezebel

Its for my work. my scripts are counted in sec/min. I would convert the
number of words to seconds and display at the top.

You dont have to give me the full code, culd u please tell me the steps at
least how it could be worked out.

I have a code that counts and displays the total length of the document.

"Jezebel" wrote:

> No, there's no easy way to do this.
>
> Why do you care how many words are on your page?
>
>
>
> "FotoArt" <FotoArt@discussions.microsoft.com> wrote in message
> news:0DC47E05-B0F3-496A-9D81-CE710D2DF5BE@microsoft.com...
> > hello everyone
> > I write news scripts in MS Word and I need my wordcount of every page
> > somewhere, preferrably on teh header.
> > Is there a way I could achieve this.
> > If the info could be updated everytime I save would be great.
> > Hope some one could help.
> >
> > thanx
> > ahmed
>
>
>

Re: put wordcount for each page on page header automatically by Greg

Greg
Fri Aug 04 13:09:29 CDT 2006

Jezebel is at lease several orders of magnitude better qualified to
answer but I will give it a stab.

When he says that there is no easy way...I would say if there is a way
it would likely be incredibly complex.

There are several factors. First what you call a page (on your machine
or as the output of your printer) is likely different if I opened your
document on my machine or printed it with my printer. A Word document
only becomes organized as pages at the output of the printerdriver
(which also drives the screen display). Different drivers = different
pages.

Secondly, creating different header text based on the content of a page
(whether that be some text or some count) is complex in itself. See:

http://gregmaxey.mvps.org/Conditional_Headers_Footers.htm for an
example.

So if you abandon the header idea then it is back to somewhere on the
page. Well that will add complexity as you will then have to figure
out how to exclude the text of the count itself.

There is a relatively simple way but it requires that you divide each
page of your document into a section (i.e., at the end of each page
insert a section break). Then you could use the following:

Sub ScratchMacro()
Dim oDoc As Document
Dim oSec As Section
Dim oRng As Range
Set oDoc = ActiveDocument
For Each oSec In oDoc.Sections
With oSec.Headers(wdHeaderFooterPrimary)
.LinkToPrevious = False
Set oRng = .Range
With oRng
.ParagraphFormat.Alignment = wdAlignParagraphRight
.Text = oSec.Range.ComputeStatistics(wdStatisticWords)
End With
End With
Next
End Sub

FotoArt wrote:
> Hello Jezebel
>
> Its for my work. my scripts are counted in sec/min. I would convert the
> number of words to seconds and display at the top.
>
> You dont have to give me the full code, culd u please tell me the steps at
> least how it could be worked out.
>
> I have a code that counts and displays the total length of the document.
>
> "Jezebel" wrote:
>
> > No, there's no easy way to do this.
> >
> > Why do you care how many words are on your page?
> >
> >
> >
> > "FotoArt" <FotoArt@discussions.microsoft.com> wrote in message
> > news:0DC47E05-B0F3-496A-9D81-CE710D2DF5BE@microsoft.com...
> > > hello everyone
> > > I write news scripts in MS Word and I need my wordcount of every page
> > > somewhere, preferrably on teh header.
> > > Is there a way I could achieve this.
> > > If the info could be updated everytime I save would be great.
> > > Hope some one could help.
> > >
> > > thanx
> > > ahmed
> >
> >
> >


Re: put wordcount for each page on page header automatically by FotoArt

FotoArt
Sat Aug 05 11:29:01 CDT 2006

Hey Greg thanx
That was just what I was looking for.
Works fine.
I cant thank you enough. You have saved me a lot of time every work hour.

cheers
ahmed

"Greg Maxey" wrote:

> Jezebel is at lease several orders of magnitude better qualified to
> answer but I will give it a stab.
>
> When he says that there is no easy way...I would say if there is a way
> it would likely be incredibly complex.
>
> There are several factors. First what you call a page (on your machine
> or as the output of your printer) is likely different if I opened your
> document on my machine or printed it with my printer. A Word document
> only becomes organized as pages at the output of the printerdriver
> (which also drives the screen display). Different drivers = different
> pages.
>
> Secondly, creating different header text based on the content of a page
> (whether that be some text or some count) is complex in itself. See:
>
> http://gregmaxey.mvps.org/Conditional_Headers_Footers.htm for an
> example.
>
> So if you abandon the header idea then it is back to somewhere on the
> page. Well that will add complexity as you will then have to figure
> out how to exclude the text of the count itself.
>
> There is a relatively simple way but it requires that you divide each
> page of your document into a section (i.e., at the end of each page
> insert a section break). Then you could use the following:
>
> Sub ScratchMacro()
> Dim oDoc As Document
> Dim oSec As Section
> Dim oRng As Range
> Set oDoc = ActiveDocument
> For Each oSec In oDoc.Sections
> With oSec.Headers(wdHeaderFooterPrimary)
> .LinkToPrevious = False
> Set oRng = .Range
> With oRng
> .ParagraphFormat.Alignment = wdAlignParagraphRight
> .Text = oSec.Range.ComputeStatistics(wdStatisticWords)
> End With
> End With
> Next
> End Sub
>
> FotoArt wrote:
> > Hello Jezebel
> >
> > Its for my work. my scripts are counted in sec/min. I would convert the
> > number of words to seconds and display at the top.
> >
> > You dont have to give me the full code, culd u please tell me the steps at
> > least how it could be worked out.
> >
> > I have a code that counts and displays the total length of the document.
> >
> > "Jezebel" wrote:
> >
> > > No, there's no easy way to do this.
> > >
> > > Why do you care how many words are on your page?
> > >
> > >
> > >
> > > "FotoArt" <FotoArt@discussions.microsoft.com> wrote in message
> > > news:0DC47E05-B0F3-496A-9D81-CE710D2DF5BE@microsoft.com...
> > > > hello everyone
> > > > I write news scripts in MS Word and I need my wordcount of every page
> > > > somewhere, preferrably on teh header.
> > > > Is there a way I could achieve this.
> > > > If the info could be updated everytime I save would be great.
> > > > Hope some one could help.
> > > >
> > > > thanx
> > > > ahmed
> > >
> > >
> > >
>
>

Re: put wordcount for each page on page header automatically by FotoArt

FotoArt
Sat Aug 05 12:11:02 CDT 2006

Hello Greg
just one more thing if you could help.
Your code works fine.
Is there a way I could add a text, lets say, "words" just before the
wordcount in the header.
And if you could please. How could I add page numbers and an additional text
on the same line in the header.
I have tried somethin like

.Text = (oSec.Range.ComputeStatistics(wdStatisticWords)) , "words"
but didnt work.

Any help would be appreciated.

thanx

ahmed

"FotoArt" wrote:

> Hey Greg thanx
> That was just what I was looking for.
> Works fine.
> I cant thank you enough. You have saved me a lot of time every work hour.
>
> cheers
> ahmed
>
> "Greg Maxey" wrote:
>
> > Jezebel is at lease several orders of magnitude better qualified to
> > answer but I will give it a stab.
> >
> > When he says that there is no easy way...I would say if there is a way
> > it would likely be incredibly complex.
> >
> > There are several factors. First what you call a page (on your machine
> > or as the output of your printer) is likely different if I opened your
> > document on my machine or printed it with my printer. A Word document
> > only becomes organized as pages at the output of the printerdriver
> > (which also drives the screen display). Different drivers = different
> > pages.
> >
> > Secondly, creating different header text based on the content of a page
> > (whether that be some text or some count) is complex in itself. See:
> >
> > http://gregmaxey.mvps.org/Conditional_Headers_Footers.htm for an
> > example.
> >
> > So if you abandon the header idea then it is back to somewhere on the
> > page. Well that will add complexity as you will then have to figure
> > out how to exclude the text of the count itself.
> >
> > There is a relatively simple way but it requires that you divide each
> > page of your document into a section (i.e., at the end of each page
> > insert a section break). Then you could use the following:
> >
> > Sub ScratchMacro()
> > Dim oDoc As Document
> > Dim oSec As Section
> > Dim oRng As Range
> > Set oDoc = ActiveDocument
> > For Each oSec In oDoc.Sections
> > With oSec.Headers(wdHeaderFooterPrimary)
> > .LinkToPrevious = False
> > Set oRng = .Range
> > With oRng
> > .ParagraphFormat.Alignment = wdAlignParagraphRight
> > .Text = oSec.Range.ComputeStatistics(wdStatisticWords)
> > End With
> > End With
> > Next
> > End Sub
> >
> > FotoArt wrote:
> > > Hello Jezebel
> > >
> > > Its for my work. my scripts are counted in sec/min. I would convert the
> > > number of words to seconds and display at the top.
> > >
> > > You dont have to give me the full code, culd u please tell me the steps at
> > > least how it could be worked out.
> > >
> > > I have a code that counts and displays the total length of the document.
> > >
> > > "Jezebel" wrote:
> > >
> > > > No, there's no easy way to do this.
> > > >
> > > > Why do you care how many words are on your page?
> > > >
> > > >
> > > >
> > > > "FotoArt" <FotoArt@discussions.microsoft.com> wrote in message
> > > > news:0DC47E05-B0F3-496A-9D81-CE710D2DF5BE@microsoft.com...
> > > > > hello everyone
> > > > > I write news scripts in MS Word and I need my wordcount of every page
> > > > > somewhere, preferrably on teh header.
> > > > > Is there a way I could achieve this.
> > > > > If the info could be updated everytime I save would be great.
> > > > > Hope some one could help.
> > > > >
> > > > > thanx
> > > > > ahmed
> > > >
> > > >
> > > >
> >
> >

Re: put wordcount for each page on page header automatically by Greg

Greg
Sat Aug 05 12:31:39 CDT 2006

Try:

Sub ScratchMacro()
Dim oDoc As Document
Dim oSec As Section
Dim oRng As Range
Set oDoc = ActiveDocument
For Each oSec In oDoc.Sections
With oSec.Headers(wdHeaderFooterPrimary)
.LinkToPrevious = False
Set oRng = .Range
With oRng
.Text = "Page Number: "
.Collapse wdCollapseEnd
.Fields.Add oRng, wdFieldPage
.Collapse wdCollapseEnd
.Move wdCharacter, 1
.Text = ". Word Count: " &
oSec.Range.ComputeStatistics(wdStatisticWords)
End With
End With
Next
End Sub


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


FotoArt wrote:
> Hello Greg
> just one more thing if you could help.
> Your code works fine.
> Is there a way I could add a text, lets say, "words" just before the
> wordcount in the header.
> And if you could please. How could I add page numbers and an
> additional text on the same line in the header.
> I have tried somethin like
>
> .Text = (oSec.Range.ComputeStatistics(wdStatisticWords)) , "words"
> but didnt work.
>
> Any help would be appreciated.
>
> thanx
>
> ahmed
>
> "FotoArt" wrote:
>
>> Hey Greg thanx
>> That was just what I was looking for.
>> Works fine.
>> I cant thank you enough. You have saved me a lot of time every work
>> hour.
>>
>> cheers
>> ahmed
>>
>> "Greg Maxey" wrote:
>>
>>> Jezebel is at lease several orders of magnitude better qualified to
>>> answer but I will give it a stab.
>>>
>>> When he says that there is no easy way...I would say if there is a
>>> way it would likely be incredibly complex.
>>>
>>> There are several factors. First what you call a page (on your
>>> machine or as the output of your printer) is likely different if I
>>> opened your document on my machine or printed it with my printer.
>>> A Word document only becomes organized as pages at the output of
>>> the printerdriver (which also drives the screen display). Different
>>> drivers = different pages.
>>>
>>> Secondly, creating different header text based on the content of a
>>> page (whether that be some text or some count) is complex in
>>> itself. See:
>>>
>>> http://gregmaxey.mvps.org/Conditional_Headers_Footers.htm for an
>>> example.
>>>
>>> So if you abandon the header idea then it is back to somewhere on
>>> the page. Well that will add complexity as you will then have to
>>> figure out how to exclude the text of the count itself.
>>>
>>> There is a relatively simple way but it requires that you divide
>>> each page of your document into a section (i.e., at the end of each
>>> page insert a section break). Then you could use the following:
>>>
>>> Sub ScratchMacro()
>>> Dim oDoc As Document
>>> Dim oSec As Section
>>> Dim oRng As Range
>>> Set oDoc = ActiveDocument
>>> For Each oSec In oDoc.Sections
>>> With oSec.Headers(wdHeaderFooterPrimary)
>>> .LinkToPrevious = False
>>> Set oRng = .Range
>>> With oRng
>>> .ParagraphFormat.Alignment = wdAlignParagraphRight
>>> .Text = oSec.Range.ComputeStatistics(wdStatisticWords)
>>> End With
>>> End With
>>> Next
>>> End Sub
>>>
>>> FotoArt wrote:
>>>> Hello Jezebel
>>>>
>>>> Its for my work. my scripts are counted in sec/min. I would
>>>> convert the number of words to seconds and display at the top.
>>>>
>>>> You dont have to give me the full code, culd u please tell me the
>>>> steps at least how it could be worked out.
>>>>
>>>> I have a code that counts and displays the total length of the
>>>> document.
>>>>
>>>> "Jezebel" wrote:
>>>>
>>>>> No, there's no easy way to do this.
>>>>>
>>>>> Why do you care how many words are on your page?
>>>>>
>>>>>
>>>>>
>>>>> "FotoArt" <FotoArt@discussions.microsoft.com> wrote in message
>>>>> news:0DC47E05-B0F3-496A-9D81-CE710D2DF5BE@microsoft.com...
>>>>>> hello everyone
>>>>>> I write news scripts in MS Word and I need my wordcount of every
>>>>>> page somewhere, preferrably on teh header.
>>>>>> Is there a way I could achieve this.
>>>>>> If the info could be updated everytime I save would be great.
>>>>>> Hope some one could help.
>>>>>>
>>>>>> thanx
>>>>>> ahmed



Re: put wordcount for each page on page header automatically by FotoArt

FotoArt
Sat Aug 05 13:01:02 CDT 2006

Hello Greg
the line below is giving a syntax error
.Text = " Word Count: " &

thanx
ahmed

"Greg Maxey" wrote:

> Try:
>
> Sub ScratchMacro()
> Dim oDoc As Document
> Dim oSec As Section
> Dim oRng As Range
> Set oDoc = ActiveDocument
> For Each oSec In oDoc.Sections
> With oSec.Headers(wdHeaderFooterPrimary)
> .LinkToPrevious = False
> Set oRng = .Range
> With oRng
> .Text = "Page Number: "
> .Collapse wdCollapseEnd
> .Fields.Add oRng, wdFieldPage
> .Collapse wdCollapseEnd
> .Move wdCharacter, 1
> .Text = ". Word Count: " &
> oSec.Range.ComputeStatistics(wdStatisticWords)
> End With
> End With
> Next
> End Sub
>
>
> --
> Greg Maxey/Word MVP
> See:
> http://gregmaxey.mvps.org/word_tips.htm
> For some helpful tips using Word.
>
>
> FotoArt wrote:
> > Hello Greg
> > just one more thing if you could help.
> > Your code works fine.
> > Is there a way I could add a text, lets say, "words" just before the
> > wordcount in the header.
> > And if you could please. How could I add page numbers and an
> > additional text on the same line in the header.
> > I have tried somethin like
> >
> > .Text = (oSec.Range.ComputeStatistics(wdStatisticWords)) , "words"
> > but didnt work.
> >
> > Any help would be appreciated.
> >
> > thanx
> >
> > ahmed
> >
> > "FotoArt" wrote:
> >
> >> Hey Greg thanx
> >> That was just what I was looking for.
> >> Works fine.
> >> I cant thank you enough. You have saved me a lot of time every work
> >> hour.
> >>
> >> cheers
> >> ahmed
> >>
> >> "Greg Maxey" wrote:
> >>
> >>> Jezebel is at lease several orders of magnitude better qualified to
> >>> answer but I will give it a stab.
> >>>
> >>> When he says that there is no easy way...I would say if there is a
> >>> way it would likely be incredibly complex.
> >>>
> >>> There are several factors. First what you call a page (on your
> >>> machine or as the output of your printer) is likely different if I
> >>> opened your document on my machine or printed it with my printer.
> >>> A Word document only becomes organized as pages at the output of
> >>> the printerdriver (which also drives the screen display). Different
> >>> drivers = different pages.
> >>>
> >>> Secondly, creating different header text based on the content of a
> >>> page (whether that be some text or some count) is complex in
> >>> itself. See:
> >>>
> >>> http://gregmaxey.mvps.org/Conditional_Headers_Footers.htm for an
> >>> example.
> >>>
> >>> So if you abandon the header idea then it is back to somewhere on
> >>> the page. Well that will add complexity as you will then have to
> >>> figure out how to exclude the text of the count itself.
> >>>
> >>> There is a relatively simple way but it requires that you divide
> >>> each page of your document into a section (i.e., at the end of each
> >>> page insert a section break). Then you could use the following:
> >>>
> >>> Sub ScratchMacro()
> >>> Dim oDoc As Document
> >>> Dim oSec As Section
> >>> Dim oRng As Range
> >>> Set oDoc = ActiveDocument
> >>> For Each oSec In oDoc.Sections
> >>> With oSec.Headers(wdHeaderFooterPrimary)
> >>> .LinkToPrevious = False
> >>> Set oRng = .Range
> >>> With oRng
> >>> .ParagraphFormat.Alignment = wdAlignParagraphRight
> >>> .Text = oSec.Range.ComputeStatistics(wdStatisticWords)
> >>> End With
> >>> End With
> >>> Next
> >>> End Sub
> >>>
> >>> FotoArt wrote:
> >>>> Hello Jezebel
> >>>>
> >>>> Its for my work. my scripts are counted in sec/min. I would
> >>>> convert the number of words to seconds and display at the top.
> >>>>
> >>>> You dont have to give me the full code, culd u please tell me the
> >>>> steps at least how it could be worked out.
> >>>>
> >>>> I have a code that counts and displays the total length of the
> >>>> document.
> >>>>
> >>>> "Jezebel" wrote:
> >>>>
> >>>>> No, there's no easy way to do this.
> >>>>>
> >>>>> Why do you care how many words are on your page?
> >>>>>
> >>>>>
> >>>>>
> >>>>> "FotoArt" <FotoArt@discussions.microsoft.com> wrote in message
> >>>>> news:0DC47E05-B0F3-496A-9D81-CE710D2DF5BE@microsoft.com...
> >>>>>> hello everyone
> >>>>>> I write news scripts in MS Word and I need my wordcount of every
> >>>>>> page somewhere, preferrably on teh header.
> >>>>>> Is there a way I could achieve this.
> >>>>>> If the info could be updated everytime I save would be great.
> >>>>>> Hope some one could help.
> >>>>>>
> >>>>>> thanx
> >>>>>> ahmed
>
>
>

Re: put wordcount for each page on page header automatically by FotoArt

FotoArt
Sat Aug 05 13:05:01 CDT 2006

Hey Greg

Its working fine
I deleted the ampersand and its working cool

thanks a lot

ahmed


"FotoArt" wrote:

> Hello Greg
> the line below is giving a syntax error
> .Text = " Word Count: " &
>
> thanx
> ahmed
>
> "Greg Maxey" wrote:
>
> > Try:
> >
> > Sub ScratchMacro()
> > Dim oDoc As Document
> > Dim oSec As Section
> > Dim oRng As Range
> > Set oDoc = ActiveDocument
> > For Each oSec In oDoc.Sections
> > With oSec.Headers(wdHeaderFooterPrimary)
> > .LinkToPrevious = False
> > Set oRng = .Range
> > With oRng
> > .Text = "Page Number: "
> > .Collapse wdCollapseEnd
> > .Fields.Add oRng, wdFieldPage
> > .Collapse wdCollapseEnd
> > .Move wdCharacter, 1
> > .Text = ". Word Count: " &
> > oSec.Range.ComputeStatistics(wdStatisticWords)
> > End With
> > End With
> > Next
> > End Sub
> >
> >
> > --
> > Greg Maxey/Word MVP
> > See:
> > http://gregmaxey.mvps.org/word_tips.htm
> > For some helpful tips using Word.
> >
> >
> > FotoArt wrote:
> > > Hello Greg
> > > just one more thing if you could help.
> > > Your code works fine.
> > > Is there a way I could add a text, lets say, "words" just before the
> > > wordcount in the header.
> > > And if you could please. How could I add page numbers and an
> > > additional text on the same line in the header.
> > > I have tried somethin like
> > >
> > > .Text = (oSec.Range.ComputeStatistics(wdStatisticWords)) , "words"
> > > but didnt work.
> > >
> > > Any help would be appreciated.
> > >
> > > thanx
> > >
> > > ahmed
> > >
> > > "FotoArt" wrote:
> > >
> > >> Hey Greg thanx
> > >> That was just what I was looking for.
> > >> Works fine.
> > >> I cant thank you enough. You have saved me a lot of time every work
> > >> hour.
> > >>
> > >> cheers
> > >> ahmed
> > >>
> > >> "Greg Maxey" wrote:
> > >>
> > >>> Jezebel is at lease several orders of magnitude better qualified to
> > >>> answer but I will give it a stab.
> > >>>
> > >>> When he says that there is no easy way...I would say if there is a
> > >>> way it would likely be incredibly complex.
> > >>>
> > >>> There are several factors. First what you call a page (on your
> > >>> machine or as the output of your printer) is likely different if I
> > >>> opened your document on my machine or printed it with my printer.
> > >>> A Word document only becomes organized as pages at the output of
> > >>> the printerdriver (which also drives the screen display). Different
> > >>> drivers = different pages.
> > >>>
> > >>> Secondly, creating different header text based on the content of a
> > >>> page (whether that be some text or some count) is complex in
> > >>> itself. See:
> > >>>
> > >>> http://gregmaxey.mvps.org/Conditional_Headers_Footers.htm for an
> > >>> example.
> > >>>
> > >>> So if you abandon the header idea then it is back to somewhere on
> > >>> the page. Well that will add complexity as you will then have to
> > >>> figure out how to exclude the text of the count itself.
> > >>>
> > >>> There is a relatively simple way but it requires that you divide
> > >>> each page of your document into a section (i.e., at the end of each
> > >>> page insert a section break). Then you could use the following:
> > >>>
> > >>> Sub ScratchMacro()
> > >>> Dim oDoc As Document
> > >>> Dim oSec As Section
> > >>> Dim oRng As Range
> > >>> Set oDoc = ActiveDocument
> > >>> For Each oSec In oDoc.Sections
> > >>> With oSec.Headers(wdHeaderFooterPrimary)
> > >>> .LinkToPrevious = False
> > >>> Set oRng = .Range
> > >>> With oRng
> > >>> .ParagraphFormat.Alignment = wdAlignParagraphRight
> > >>> .Text = oSec.Range.ComputeStatistics(wdStatisticWords)
> > >>> End With
> > >>> End With
> > >>> Next
> > >>> End Sub
> > >>>
> > >>> FotoArt wrote:
> > >>>> Hello Jezebel
> > >>>>
> > >>>> Its for my work. my scripts are counted in sec/min. I would
> > >>>> convert the number of words to seconds and display at the top.
> > >>>>
> > >>>> You dont have to give me the full code, culd u please tell me the
> > >>>> steps at least how it could be worked out.
> > >>>>
> > >>>> I have a code that counts and displays the total length of the
> > >>>> document.
> > >>>>
> > >>>> "Jezebel" wrote:
> > >>>>
> > >>>>> No, there's no easy way to do this.
> > >>>>>
> > >>>>> Why do you care how many words are on your page?
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>> "FotoArt" <FotoArt@discussions.microsoft.com> wrote in message
> > >>>>> news:0DC47E05-B0F3-496A-9D81-CE710D2DF5BE@microsoft.com...
> > >>>>>> hello everyone
> > >>>>>> I write news scripts in MS Word and I need my wordcount of every
> > >>>>>> page somewhere, preferrably on teh header.
> > >>>>>> Is there a way I could achieve this.
> > >>>>>> If the info could be updated everytime I save would be great.
> > >>>>>> Hope some one could help.
> > >>>>>>
> > >>>>>> thanx
> > >>>>>> ahmed
> >
> >
> >

Re: put wordcount for each page on page header automatically by FotoArt

FotoArt
Sun Aug 06 08:16:01 CDT 2006

hello greg

i have modified the code as follows

Sub ScratchMacro()
Dim lngWords As Long
Dim pMinutes As Long
Dim oDoc As Document
Dim oSec As Section
Dim oRng As Range
Set oDoc = ActiveDocument


For Each oSec In oDoc.Sections
With oSec.Headers(wdHeaderFooterPrimary)
.LinkToPrevious = False
Set oRng = .Range
With oRng
.Text = "Page: "
.Collapse wdCollapseEnd
.Fields.Add oRng, wdFieldPage
.Collapse wdCollapseEnd
.Move wdCharacter, 1
lngWords = oSec.Range.ComputeStatistics(wdStatisticWords)
pMinutes = (lngWords / 3)
.Text = " Length: " & Format$(pMinutes / 86400, "hh:mm:ss")
.Collapse wdCollapseEnd
.Fields.Add oRng, wdFieldDate, "\@ ddd-d-MMM-yyyy"
.Text = " Date: "

End With
End With


Any idea why the length and date wouldnt show up after page 9 of any
document. However the page number is shown until the end of the documnt.
every new page is a new section.

Any help would be appreciated

thanx
ahmed
"FotoArt" wrote:

> Hey Greg
>
> Its working fine
> I deleted the ampersand and its working cool
>
> thanks a lot
>
> ahmed
>
>
> "FotoArt" wrote:
>
> > Hello Greg
> > the line below is giving a syntax error
> > .Text = " Word Count: " &
> >
> > thanx
> > ahmed
> >
> > "Greg Maxey" wrote:
> >
> > > Try:
> > >
> > > Sub ScratchMacro()
> > > Dim oDoc As Document
> > > Dim oSec As Section
> > > Dim oRng As Range
> > > Set oDoc = ActiveDocument
> > > For Each oSec In oDoc.Sections
> > > With oSec.Headers(wdHeaderFooterPrimary)
> > > .LinkToPrevious = False
> > > Set oRng = .Range
> > > With oRng
> > > .Text = "Page Number: "
> > > .Collapse wdCollapseEnd
> > > .Fields.Add oRng, wdFieldPage
> > > .Collapse wdCollapseEnd
> > > .Move wdCharacter, 1
> > > .Text = ". Word Count: " &
> > > oSec.Range.ComputeStatistics(wdStatisticWords)
> > > End With
> > > End With
> > > Next
> > > End Sub
> > >
> > >
> > > --
> > > Greg Maxey/Word MVP
> > > See:
> > > http://gregmaxey.mvps.org/word_tips.htm
> > > For some helpful tips using Word.
> > >
> > >
> > > FotoArt wrote:
> > > > Hello Greg
> > > > just one more thing if you could help.
> > > > Your code works fine.
> > > > Is there a way I could add a text, lets say, "words" just before the
> > > > wordcount in the header.
> > > > And if you could please. How could I add page numbers and an
> > > > additional text on the same line in the header.
> > > > I have tried somethin like
> > > >
> > > > .Text = (oSec.Range.ComputeStatistics(wdStatisticWords)) , "words"
> > > > but didnt work.
> > > >
> > > > Any help would be appreciated.
> > > >
> > > > thanx
> > > >
> > > > ahmed
> > > >
> > > > "FotoArt" wrote:
> > > >
> > > >> Hey Greg thanx
> > > >> That was just what I was looking for.
> > > >> Works fine.
> > > >> I cant thank you enough. You have saved me a lot of time every work
> > > >> hour.
> > > >>
> > > >> cheers
> > > >> ahmed
> > > >>
> > > >> "Greg Maxey" wrote:
> > > >>
> > > >>> Jezebel is at lease several orders of magnitude better qualified to
> > > >>> answer but I will give it a stab.
> > > >>>
> > > >>> When he says that there is no easy way...I would say if there is a
> > > >>> way it would likely be incredibly complex.
> > > >>>
> > > >>> There are several factors. First what you call a page (on your
> > > >>> machine or as the output of your printer) is likely different if I
> > > >>> opened your document on my machine or printed it with my printer.
> > > >>> A Word document only becomes organized as pages at the output of
> > > >>> the printerdriver (which also drives the screen display). Different
> > > >>> drivers = different pages.
> > > >>>
> > > >>> Secondly, creating different header text based on the content of a
> > > >>> page (whether that be some text or some count) is complex in
> > > >>> itself. See:
> > > >>>
> > > >>> http://gregmaxey.mvps.org/Conditional_Headers_Footers.htm for an
> > > >>> example.
> > > >>>
> > > >>> So if you abandon the header idea then it is back to somewhere on
> > > >>> the page. Well that will add complexity as you will then have to
> > > >>> figure out how to exclude the text of the count itself.
> > > >>>
> > > >>> There is a relatively simple way but it requires that you divide
> > > >>> each page of your document into a section (i.e., at the end of each
> > > >>> page insert a section break). Then you could use the following:
> > > >>>
> > > >>> Sub ScratchMacro()
> > > >>> Dim oDoc As Document
> > > >>> Dim oSec As Section
> > > >>> Dim oRng As Range
> > > >>> Set oDoc = ActiveDocument
> > > >>> For Each oSec In oDoc.Sections
> > > >>> With oSec.Headers(wdHeaderFooterPrimary)
> > > >>> .LinkToPrevious = False
> > > >>> Set oRng = .Range
> > > >>> With oRng
> > > >>> .ParagraphFormat.Alignment = wdAlignParagraphRight
> > > >>> .Text = oSec.Range.ComputeStatistics(wdStatisticWords)
> > > >>> End With
> > > >>> End With
> > > >>> Next
> > > >>> End Sub
> > > >>>
> > > >>> FotoArt wrote:
> > > >>>> Hello Jezebel
> > > >>>>
> > > >>>> Its for my work. my scripts are counted in sec/min. I would
> > > >>>> convert the number of words to seconds and display at the top.
> > > >>>>
> > > >>>> You dont have to give me the full code, culd u please tell me the
> > > >>>> steps at least how it could be worked out.
> > > >>>>
> > > >>>> I have a code that counts and displays the total length of the
> > > >>>> document.
> > > >>>>
> > > >>>> "Jezebel" wrote:
> > > >>>>
> > > >>>>> No, there's no easy way to do this.
> > > >>>>>
> > > >>>>> Why do you care how many words are on your page?
> > > >>>>>
> > > >>>>>
> > > >>>>>
> > > >>>>> "FotoArt" <FotoArt@discussions.microsoft.com> wrote in message
> > > >>>>> news:0DC47E05-B0F3-496A-9D81-CE710D2DF5BE@microsoft.com...
> > > >>>>>> hello everyone
> > > >>>>>> I write news scripts in MS Word and I need my wordcount of every
> > > >>>>>> page somewhere, preferrably on teh header.
> > > >>>>>> Is there a way I could achieve this.
> > > >>>>>> If the info could be updated everytime I save would be great.
> > > >>>>>> Hope some one could help.
> > > >>>>>>
> > > >>>>>> thanx
> > > >>>>>> ahmed
> > >
> > >
> > >

Re: put wordcount for each page on page header automatically by Greg

Greg
Sun Aug 06 11:06:41 CDT 2006

This was a puzzle ;-). It has to do with the move character statement.
When the number of pages exceeded one digit then it messed up.

Change:
.Move wdCharacter, 1
To:

.Move wdCharacter, 2 'or 3 if you have more than 99 pages.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


FotoArt wrote:
> hello greg
>
> i have modified the code as follows
>
> Sub ScratchMacro()
> Dim lngWords As Long
> Dim pMinutes As Long
> Dim oDoc As Document
> Dim oSec As Section
> Dim oRng As Range
> Set oDoc = ActiveDocument
>
>
> For Each oSec In oDoc.Sections
> With oSec.Headers(wdHeaderFooterPrimary)
> .LinkToPrevious = False
> Set oRng = .Range
> With oRng
> .Text = "Page: "
> .Collapse wdCollapseEnd
> .Fields.Add oRng, wdFieldPage
> .Collapse wdCollapseEnd
> .Move wdCharacter, 1
> lngWords = oSec.Range.ComputeStatistics(wdStatisticWords)
> pMinutes = (lngWords / 3)
> .Text = " Length: " & Format$(pMinutes / 86400, "hh:mm:ss")
> .Collapse wdCollapseEnd
> .Fields.Add oRng, wdFieldDate, "\@ ddd-d-MMM-yyyy"
> .Text = " Date: "
>
> End With
> End With
>
>
> Any idea why the length and date wouldnt show up after page 9 of any
> document. However the page number is shown until the end of the
> documnt. every new page is a new section.
>
> Any help would be appreciated
>
> thanx
> ahmed
> "FotoArt" wrote:
>
>> Hey Greg
>>
>> Its working fine
>> I deleted the ampersand and its working cool
>>
>> thanks a lot
>>
>> ahmed
>>
>>
>> "FotoArt" wrote:
>>
>>> Hello Greg
>>> the line below is giving a syntax error
>>> .Text = " Word Count: " &
>>>
>>> thanx
>>> ahmed
>>>
>>> "Greg Maxey" wrote:
>>>
>>>> Try:
>>>>
>>>> Sub ScratchMacro()
>>>> Dim oDoc As Document
>>>> Dim oSec As Section
>>>> Dim oRng As Range
>>>> Set oDoc = ActiveDocument
>>>> For Each oSec In oDoc.Sections
>>>> With oSec.Headers(wdHeaderFooterPrimary)
>>>> .LinkToPrevious = False
>>>> Set oRng = .Range
>>>> With oRng
>>>> .Text = "Page Number: "
>>>> .Collapse wdCollapseEnd
>>>> .Fields.Add oRng, wdFieldPage
>>>> .Collapse wdCollapseEnd
>>>> .Move wdCharacter, 1
>>>> .Text = ". Word Count: " &
>>>> oSec.Range.ComputeStatistics(wdStatisticWords)
>>>> End With
>>>> End With
>>>> Next
>>>> End Sub
>>>>
>>>>
>>>> --
>>>> Greg Maxey/Word MVP
>>>> See:
>>>> http://gregmaxey.mvps.org/word_tips.htm
>>>> For some helpful tips using Word.
>>>>
>>>>
>>>> FotoArt wrote:
>>>>> Hello Greg
>>>>> just one more thing if you could help.
>>>>> Your code works fine.
>>>>> Is there a way I could add a text, lets say, "words" just before
>>>>> the wordcount in the header.
>>>>> And if you could please. How could I add page numbers and an
>>>>> additional text on the same line in the header.
>>>>> I have tried somethin like
>>>>>
>>>>> .Text = (oSec.Range.ComputeStatistics(wdStatisticWords)) , "words"
>>>>> but didnt work.
>>>>>
>>>>> Any help would be appreciated.
>>>>>
>>>>> thanx
>>>>>
>>>>> ahmed
>>>>>
>>>>> "FotoArt" wrote:
>>>>>
>>>>>> Hey Greg thanx
>>>>>> That was just what I was looking for.
>>>>>> Works fine.
>>>>>> I cant thank you enough. You have saved me a lot of time every
>>>>>> work hour.
>>>>>>
>>>>>> cheers
>>>>>> ahmed
>>>>>>
>>>>>> "Greg Maxey" wrote:
>>>>>>
>>>>>>> Jezebel is at lease several orders of magnitude better
>>>>>>> qualified to answer but I will give it a stab.
>>>>>>>
>>>>>>> When he says that there is no easy way...I would say if there
>>>>>>> is a way it would likely be incredibly complex.
>>>>>>>
>>>>>>> There are several factors. First what you call a page (on your
>>>>>>> machine or as the output of your printer) is likely different
>>>>>>> if I opened your document on my machine or printed it with my
>>>>>>> printer. A Word document only becomes organized as pages at the
>>>>>>> output of the printerdriver (which also drives the screen
>>>>>>> display). Different drivers = different pages.
>>>>>>>
>>>>>>> Secondly, creating different header text based on the content
>>>>>>> of a page (whether that be some text or some count) is complex
>>>>>>> in itself. See:
>>>>>>>
>>>>>>> http://gregmaxey.mvps.org/Conditional_Headers_Footers.htm for an
>>>>>>> example.
>>>>>>>
>>>>>>> So if you abandon the header idea then it is back to somewhere
>>>>>>> on the page. Well that will add complexity as you will then
>>>>>>> have to figure out how to exclude the text of the count itself.
>>>>>>>
>>>>>>> There is a relatively simple way but it requires that you divide
>>>>>>> each page of your document into a section (i.e., at the end of
>>>>>>> each page insert a section break). Then you could use the
>>>>>>> following:
>>>>>>>
>>>>>>> Sub ScratchMacro()
>>>>>>> Dim oDoc As Document
>>>>>>> Dim oSec As Section
>>>>>>> Dim oRng As Range
>>>>>>> Set oDoc = ActiveDocument
>>>>>>> For Each oSec In oDoc.Sections
>>>>>>> With oSec.Headers(wdHeaderFooterPrimary)
>>>>>>> .LinkToPrevious = False
>>>>>>> Set oRng = .Range
>>>>>>> With oRng
>>>>>>> .ParagraphFormat.Alignment = wdAlignParagraphRight
>>>>>>> .Text = oSec.Range.ComputeStatistics(wdStatisticWords)
>>>>>>> End With
>>>>>>> End With
>>>>>>> Next
>>>>>>> End Sub
>>>>>>>
>>>>>>> FotoArt wrote:
>>>>>>>> Hello Jezebel
>>>>>>>>
>>>>>>>> Its for my work. my scripts are counted in sec/min. I would
>>>>>>>> convert the number of words to seconds and display at the top.
>>>>>>>>
>>>>>>>> You dont have to give me the full code, culd u please tell me
>>>>>>>> the steps at least how it could be worked out.
>>>>>>>>
>>>>>>>> I have a code that counts and displays the total length of the
>>>>>>>> document.
>>>>>>>>
>>>>>>>> "Jezebel" wrote:
>>>>>>>>
>>>>>>>>> No, there's no easy way to do this.
>>>>>>>>>
>>>>>>>>> Why do you care how many words are on your page?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> "FotoArt" <FotoArt@discussions.microsoft.com> wrote in message
>>>>>>>>> news:0DC47E05-B0F3-496A-9D81-CE710D2DF5BE@microsoft.com...
>>>>>>>>>> hello everyone
>>>>>>>>>> I write news scripts in MS Word and I need my wordcount of
>>>>>>>>>> every page somewhere, preferrably on teh header.
>>>>>>>>>> Is there a way I could achieve this.
>>>>>>>>>> If the info could be updated everytime I save would be great.
>>>>>>>>>> Hope some one could help.
>>>>>>>>>>
>>>>>>>>>> thanx
>>>>>>>>>> ahmed



Re: put wordcount for each page on page header automatically by FotoArt

FotoArt
Sun Aug 06 12:33:01 CDT 2006

Hello Greg

thanx for the help
Its working fine

Ahmed

"Greg Maxey" wrote:

> This was a puzzle ;-). It has to do with the move character statement.
> When the number of pages exceeded one digit then it messed up.
>
> Change:
> .Move wdCharacter, 1
> To:
>
> .Move wdCharacter, 2 'or 3 if you have more than 99 pages.
>
>
>
> --
> Greg Maxey/Word MVP
> See:
> http://gregmaxey.mvps.org/word_tips.htm
> For some helpful tips using Word.
>
>
> FotoArt wrote:
> > hello greg
> >
> > i have modified the code as follows
> >
> > Sub ScratchMacro()
> > Dim lngWords As Long
> > Dim pMinutes As Long
> > Dim oDoc As Document
> > Dim oSec As Section
> > Dim oRng As Range
> > Set oDoc = ActiveDocument
> >
> >
> > For Each oSec In oDoc.Sections
> > With oSec.Headers(wdHeaderFooterPrimary)
> > .LinkToPrevious = False
> > Set oRng = .Range
> > With oRng
> > .Text = "Page: "
> > .Collapse wdCollapseEnd
> > .Fields.Add oRng, wdFieldPage
> > .Collapse wdCollapseEnd
> > .Move wdCharacter, 1
> > lngWords = oSec.Range.ComputeStatistics(wdStatisticWords)
> > pMinutes = (lngWords / 3)
> > .Text = " Length: " & Format$(pMinutes / 86400, "hh:mm:ss")
> > .Collapse wdCollapseEnd
> > .Fields.Add oRng, wdFieldDate, "\@ ddd-d-MMM-yyyy"
> > .Text = " Date: "
> >
> > End With
> > End With
> >
> >
> > Any idea why the length and date wouldnt show up after page 9 of any
> > document. However the page number is shown until the end of the
> > documnt. every new page is a new section.
> >
> > Any help would be appreciated
> >
> > thanx
> > ahmed
> > "FotoArt" wrote:
> >
> >> Hey Greg
> >>
> >> Its working fine
> >> I deleted the ampersand and its working cool
> >>
> >> thanks a lot
> >>
> >> ahmed
> >>
> >>
> >> "FotoArt" wrote:
> >>
> >>> Hello Greg
> >>> the line below is giving a syntax error
> >>> .Text = " Word Count: " &
> >>>
> >>> thanx
> >>> ahmed
> >>>
> >>> "Greg Maxey" wrote:
> >>>
> >>>> Try:
> >>>>
> >>>> Sub ScratchMacro()
> >>>> Dim oDoc As Document
> >>>> Dim oSec As Section
> >>>> Dim oRng As Range
> >>>> Set oDoc = ActiveDocument
> >>>> For Each oSec In oDoc.Sections
> >>>> With oSec.Headers(wdHeaderFooterPrimary)
> &