Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Word's Word Count (Word 2000)

    Hello Everyone.

    I'm using a custom form with this code below to automatically update all my header and footer info in my documents. For some reason everytime I show the form Word performs a word count
    and I'm finding that on our user population it is taking a long time. My machine is rather fast so it never slowed me down much. I've tried to turn off Word Count by: Application.options.pagination = false, but this
    sometimes seems to work and most of the time does not.

    Anyone have a suggestion?

    Thank you,

    Kyle


    gofrmHeaderInfo.txtAuthor.Text = _
    ActiveDocument.BuiltInDocumentProperties(wdPropert yAuthor)
    gofrmHeaderInfo.txtComments.Text = _
    ActiveDocument.BuiltInDocumentProperties(wdPropert yComments)
    gofrmHeaderInfo.txtDrugName.Text = _
    ActiveDocument.BuiltInDocumentProperties(wdPropert ySubject)
    If Left(ActiveDocument.AttachedTemplate.Name, 3) = "CTD" Then
    strMyTitle = Replace(ActiveDocument.AttachedTemplate.Name, ").dot", "")
    strMyTitle = Replace(strMyTitle, "", "", 17)
    gofrmHeaderInfo.txtTitle = strMyTitle
    Else
    gofrmHeaderInfo.txtTitle = ActiveDocument.BuiltInDocumentProperties(wdPropert yTitle)
    End If

    If ActiveDocument.BuiltInDocumentProperties(wdPropert yKeywords).Value <> "" Then
    iStart = InStr(1, ActiveDocument.BuiltInDocumentProperties(wdPropert yKeywords).Value, ".", 0)
    strVersionNo1 = (Trim(Mid(ActiveDocument.BuiltInDocumentProperties (wdPropertyKeywords).Value, iStart - 2, 2)))
    strVersionNo2 = (Trim(Mid(ActiveDocument.BuiltInDocumentProperties (wdPropertyKeywords).Value, iStart, 2)))
    strVersionNo2 = Replace(strVersionNo2, ".", "")
    gofrmHeaderInfo.txtVersionNo1.Text = strVersionNo1
    gofrmHeaderInfo.txtVersionNo2.Text = strVersionNo2
    Else
    gofrmHeaderInfo.txtVersionNo1.Text = 0
    gofrmHeaderInfo.txtVersionNo2.Text = 1
    End If

  2. #2
    Star Lounger
    Join Date
    Jan 2003
    Location
    San Francisco, California, USA
    Posts
    93
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Word's Word Count (Word 2000)

    Thanks so much. It still does a word count but after I click OK on my form. I'd much rather have it that way then before the form loads.

    Kyle

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Word's Word Count (Word 2000)

    <P ID="edit" class=small>(Edited by jscher2000 on 19-Jun-03 19:43. Nothing important, just forgot to bold something.)</P>Well, the Statistics tab of the File>Properties dialog triggers a word count, but the other tabs don't. Apparently, using the BuiltinProperties collection refreshes the statistics even if you are not asking for them.

    So you have to go around the "clean" way to code and do it off the Summary Information tab of the File>Properties... dialog:

    <pre>With Dialogs(wdDialogFileSummaryInfo)
    gofrmHeaderInfo.txtAuthor.Text = .Author
    gofrmHeaderInfo.txtComments.Text = .Comments
    gofrmHeaderInfo.txtDrugName.Text = .Subject
    If Left(ActiveDocument.AttachedTemplate.Name, 3) = "CTD" Then
    strMyTitle = Replace(ActiveDocument.AttachedTemplate.Name, ").dot", "")
    strMyTitle = Replace(strMyTitle, "", "", 17)
    gofrmHeaderInfo.txtTitle = strMyTitle
    Else
    gofrmHeaderInfo.txtTitle = .Title
    End If
    If .Keywords <> "" Then
    iStart = InStr(1, .Keywords, ".", 0)
    strVersionNo1 = (Trim(Mid(.Keywords, iStart - 2, 2)))
    strVersionNo2 = (Trim(Mid(.Keywords, iStart, 2)))
    strVersionNo2 = Replace(strVersionNo2, ".", "")
    gofrmHeaderInfo.txtVersionNo1.Text = strVersionNo1
    gofrmHeaderInfo.txtVersionNo2.Text = strVersionNo2
    Else
    gofrmHeaderInfo.txtVersionNo1.Text = 0
    gofrmHeaderInfo.txtVersionNo2.Text = 1
    End If
    End With</pre>

    So it's not pretty. I think it bypasses the problem. Does it work in your environment?

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Word's Word Count (Word 2000)

    Hi Kyle,

    You might be able to avoid the issue altogether by using Word fields to extract the docproperty information you need, since all of it looks to be accessible that way. The idea is to either use fields to display the information (which is what you seem to be doing in some cases), or to provide a string for the macro to test (which you also seem to be doing). For the latter, you'd create a field to obtain the basic string, copy it, delete the field, then process the string. On large document/slow PC combinations, this might be much quicker than what you've been doing since (I think) it avoids Word's re-calc.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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