• WSChris Green

    WSChris Green

    @wschris-green

    Viewing 15 replies - 1 through 15 (of 107 total)
    Author
    Replies
    • in reply to: For Each (XP) #630499

      Ahh. I see it now. When I first tested, I didn’t compile before testing. It was the compile time that caused the 9 to 4.5 second disparity. After compile, both your code and the stuff I wrote runs faster with For Each. Thanks.

    • in reply to: For Each (XP) #630486

      Thanks for responding, guys. Interesting little lesson, here.

      I took my work machine home. Wanted to test on the same file. It’s got 48 tables, some of them rather long. It’s also got a lot of embedded graphics. Original file size over 5 Mb. I stripped out the graphics to get a svelte 450 Kb file so I could get it on floppy.

      After stripping out the graphics, there’s no appreciable difference. A hundredth of a second or so between the two routines. It looks like graphics/file size really slows down the collection method (in this case, twice as long).

      Also, I was surprised at the nominal difference between the two machines on the file without graphics. Home machine: Win 98 SE, AMD K3 600 MHz, 192 MB, Word 2K ran at 3.5 seconds. Work machine Win XP, P4 1.7 GHz, 512 MB, Word XP ran at 3.3 seconds.

      Sub TestInc()
      
      Dim i As Integer, j As Integer
      Dim Begin: Begin = Timer
      Dim sngWid As Single
      
      For j = ActiveDocument.Tables.Count To 1 Step -1
          sngWid = 6.5 / ActiveDocument.Tables(j).Columns.Count
          For i = 1 To ActiveDocument.Tables(j).Columns.Count
              ActiveDocument.Tables(j).Columns(i).Width = InchesToPoints(sngWid)
          Next
      Next
      
      MsgBox "It took " & Timer - Begin & " seconds."
      
      End Sub
      
      Sub TestFor()
      Dim oTab As Table
      Dim i As Integer, j As Integer
      Dim Begin: Begin = Timer
      Dim sngWid As Single
      
      For Each oTab In ActiveDocument.Tables
          sngWid = 6.5 / oTab.Columns.Count
          For i = 1 To oTab.Columns.Count
              oTab.Columns(i).Width = InchesToPoints(sngWid)
          Next
      Next
      
      MsgBox "It took " & Timer - Begin & " seconds."
      
      End Sub
      
    • in reply to: Getting hold of styles in template (Word 2k) #577270

      Hi Arild,

      When you attach a new template, styles don’t automatically come over. Use the Organizer (Format>Styles>Organizer Button) to copy the styles from your template to the document..

      HTH,

      Chris

    • in reply to: Mail Merge Protected Forms (Word 2k, 2002) #573866

      I tried from Outlook. The only mail merge I could find was using Contacts. I wanted to use an external data source. In fact, Outlook help leads you in the direction of using Word’s mail merge. Still baffled as to the rationale behind protected forms being *so* protected. 🙂

    • in reply to: Headings and Page Breaks (Word 97 SR2) #573515

      Hi Ron,

      How about creating another heading style (“Heading 2 w/ Page Break”) and setting the Page Break Before property?

      HTH,

      Chris

    • in reply to: Grayed Out MRU (Word 2002) #572840

      Hi Kevin,

      How about this?

    • in reply to: Misuse of templates (W2K) #556672

      Hi Howard,

      I’m aware of that. Perhaps I was unclear. My point was that you could use FileSearch to open only files with a .doc extension and a file type of template, eliminating the need to open every document and test its type from ActiveDocument.

      Regards,

      Chris

    • in reply to: Misuse of templates (W2K) #556310

      Or, use FileSearch to open the docs and set .FileName to “*.doc” and .FileType to msoFileTypeTemplates. That should target the offending files pretty well.

      HTH,

      Chris

    • in reply to: Remove Character Style but Leave Manual Formatting (2000) #550692

      Oop. I forgot it needs to work on a selection…

    • in reply to: Remove Character Style but Leave Manual Formatting (2000) #550691

      Aha! Now we’re gettin’ somewhere. Why use a dummy doc at all?

      ActiveDocument.Styles("Testing").Delete
      ActiveDocument.Styles.Add Name:="Testing", Type:=wdStyleTypeCharacter
      With ActiveDocument.Styles("Testing")
          .Font.Color = wdColorBlue
          '.Font.etc = whatever
      End With
      
    • in reply to: Remove Character Style but Leave Manual Formatting (2000) #550573

      Hi Lin,

      I agree. smile That’s why I said in the last post, “The replace with new character style seems much better. ”

      I proposed the code as an exercise in near futility, as it’s so inefficient. Hopefully, one of the VBA Gurus can come up with something else.

      Why come up with something else? JFinkle could create a new character style on which to base the replace. The old style had attributes of Hidden, Blue, and Italic. He creates a new character style of Not Hidden, Not Blue, and Not Italic. But, what if those attributes conflict with some of his paragraph styles? For example, an Italicized Heading style or a blue First Row Table style. In that case, the replace would cause problems with existing paragraph styles that had been modified with the old character style.

      When I said the code used brute-force I was being generous. One would have to read and assign every font attribute they were concerned about. It then examines every character in a selection and sez, “If you’re the old character style, tell me everthing about the font I want to know, reset it to the paragraph style, and apply everything you told me about the font.” Usable. But not fun.

      Chris

    • in reply to: Remove Character Style but Leave Manual Formatting (2000) #550561

      All I could think of off-hand was brute force. The replace with new character style seems much better.

      But, if you’re interested, here’s a snippet. You’d have to read into the array the font attributes you want to preserve. There’s got to be a more elegant way, but I haven’t found it. It’ll be sloooooowww. Especially if you have a lot of text in that particular character style.

      Sub ResetCharacter()
      '
      Dim varFont(4)
      Dim oChar As Object
      Dim oStyle As Style
      
      For Each oChar In Selection.Characters
          If oChar.Style = "Testing" Then
              varFont(1) = oChar.Font.Bold
              varFont(2) = oChar.Font.Subscript
              varFont(3) = oChar.Font.Underline
              varFont(4) = oChar.Font.Superscript
              oChar.Font.Reset
              oChar.Font.Bold = varFont(1)
              oChar.Font.Bold = varFont(1)
              oChar.Font.Subscript = varFont(2)
              oChar.Font.Underline = varFont(3)
              oChar.Font.Superscript = varFont(4)
          End If
      Next
      MsgBox "Done"
      
      End Sub
      
    • in reply to: Remove Character Style but Leave Manual Formatting (2000) #550506

      I’m confused. You *don’t* want to remove text with the character style from the document.

      Do you want to undo the character style without impacting manual formatting on other text in the paragraph?

      What about a macro that aplies the ctrl+spacebar only to the character style? Mind you, if they apply manual formatting to the character style, you’ll lose it. But it’s better than losing all manual formatting.

      Sub ResetCharacter()
      '
      Selection.Find.ClearFormatting
      With Selection.Find
          .Style = "instructions"
          .Wrap = wdFindContinue
          Do
              .Execute
              Selection.Font.Reset
          Loop Until .Found = False
      End With
      End Sub
      

      HTH,

      Chris

    • in reply to: Remove Character Style but Leave Manual Formatting (2000) #550492

      Instruct users on how to (or create a macro to) use Find/Replace to replace style “Instructions” with nothing.

      HTH,

      Chris

    • in reply to: I have 20 people that use Term (Outlook 98, Excel 97) #550302

      Hi Daniel,

      You might want to grab the install root value from the registry and append it to your shell string. For Office 97, I believe it’s HKEY_Local_MachineSoftwareMicrosoftOffice8.0CommonInstallRoot.

      HTH,

      Chris

    Viewing 15 replies - 1 through 15 (of 107 total)