• WSAndrew77

    WSAndrew77

    @wsandrew77

    Viewing 15 replies - 541 through 555 (of 578 total)
    Author
    Replies
    • in reply to: Stopping Task Pane from Opening (2003) #833470

      If you can’t get that Add-In to work, you can make the change yourself in the Registry.

      Requisite warning about being careful when editing the registry. Just take it slow. You’re making a real minor change here.

      Go to Start -> Run, and Run regedit.exe

      Navigate to:

      HKEY_CURRENT_USERSoftwareMicrosoftOffice11.0CommonGeneral

      Select the “DoNotDismissFileNewTaskPane” key. Change its value from 1 to 0.

      Exit regedit and restart Word. Word will now follow whatever setting you have for the Task Pane in Tools->Options->View

      HTH

    • in reply to: Find Super/Sub script (XP) #833240

      Hans has pointed you in the right direction on this one, but as a sidebar, there are times when your initial approach may be useful or even necessary. When that happens, there’s a few things you can do to speed up your code.

      For example, when using Find/Replace, you can search for Highlighting, but you can’t specify which color. So if you’ve got a document that uses red and blue highlighting, and you only want to clear the red highlighting, you’re in a bind. It can be done using the Find object, but it’s much easier to code (and understand) if you use a simple For…Each loop, which is is much faster than a regular For…Next loop.

      To solve our hypothetical highlighting problem:

      Sub RemoveOnlyRedHighlighting()
      Dim char As Range
      For Each char In ActiveDocument.Characters
          If char.HighlightColorIndex = wdRed Then
              char.HighlightColorIndex = wdNoHighlight
          End If
      Next char
      End Sub
      

      In general, use a For…Each loop when you’ll be visiting each object in a collection of objects, as long as you’re not deleting any of them.

      This wouldn’t be as fast as using the Find object, but its performance is respectable, considering it hits each character. And it’s got the added benefit of being simple to code — a similar macro using the Find object would be about three times as long.

      To see how much faster a For…Each loop is, try this version of your original code:

      Sub AnySuperOrSubScripts()
      Dim char As Range
      For Each char In ActiveDocument.Characters
          If (char.Font.Subscript) Or _
              (char.Font.Superscript) Then
              MsgBox "There are superscript or subscript characters " & _
                     "present in this document!", vbInformation, _
                     "Reformat"
              Exit For
          End If
      Next char
      End Sub
      

      Since you just wanted to know if there were any sub/super script, this version stops as soon as it finds any.
      BTW, just like the Find object, this method won’t catch items in the Header/Footer, or in Footnotes, Comments, etc.

      Just my $.02

    • in reply to: Find Super/Sub script (XP) #833241

      Hans has pointed you in the right direction on this one, but as a sidebar, there are times when your initial approach may be useful or even necessary. When that happens, there’s a few things you can do to speed up your code.

      For example, when using Find/Replace, you can search for Highlighting, but you can’t specify which color. So if you’ve got a document that uses red and blue highlighting, and you only want to clear the red highlighting, you’re in a bind. It can be done using the Find object, but it’s much easier to code (and understand) if you use a simple For…Each loop, which is is much faster than a regular For…Next loop.

      To solve our hypothetical highlighting problem:

      Sub RemoveOnlyRedHighlighting()
      Dim char As Range
      For Each char In ActiveDocument.Characters
          If char.HighlightColorIndex = wdRed Then
              char.HighlightColorIndex = wdNoHighlight
          End If
      Next char
      End Sub
      

      In general, use a For…Each loop when you’ll be visiting each object in a collection of objects, as long as you’re not deleting any of them.

      This wouldn’t be as fast as using the Find object, but its performance is respectable, considering it hits each character. And it’s got the added benefit of being simple to code — a similar macro using the Find object would be about three times as long.

      To see how much faster a For…Each loop is, try this version of your original code:

      Sub AnySuperOrSubScripts()
      Dim char As Range
      For Each char In ActiveDocument.Characters
          If (char.Font.Subscript) Or _
              (char.Font.Superscript) Then
              MsgBox "There are superscript or subscript characters " & _
                     "present in this document!", vbInformation, _
                     "Reformat"
              Exit For
          End If
      Next char
      End Sub
      

      Since you just wanted to know if there were any sub/super script, this version stops as soon as it finds any.
      BTW, just like the Find object, this method won’t catch items in the Header/Footer, or in Footnotes, Comments, etc.

      Just my $.02

    • in reply to: Invalid Charaters (VBA) #832230

      Hi Randall

      Yet another way:

      Function IsValidFileName(sFileName As String) As Boolean
      If (sFileName Like "*[?*:/{}]*" Or _
          sFileName Like "*[[]*" Or _
          sFileName Like "*[]]*") Then
         IsValidFileName = False
      Else
         IsValidFileName = True
      End If
      End Function
      
    • in reply to: Invalid Charaters (VBA) #832231

      Hi Randall

      Yet another way:

      Function IsValidFileName(sFileName As String) As Boolean
      If (sFileName Like "*[?*:/{}]*" Or _
          sFileName Like "*[[]*" Or _
          sFileName Like "*[]]*") Then
         IsValidFileName = False
      Else
         IsValidFileName = True
      End If
      End Function
      
    • in reply to: Use Find without selecting (2002) #831228

      Hi Jeanie,

      I think this is what you’re looking for:

      Sub MoveToNextHeading()
      With Selection
          With .Find
              .ClearFormatting
              .Text = "^p^p"
              .Replacement.Text = ""
              .Forward = True
              .Wrap = wdFindAsk
              .Format = False
              .MatchCase = False
              .MatchWholeWord = False
              .MatchWildcards = False
              .MatchSoundsLike = False
              .MatchAllWordForms = False
          End With
          
          If (.Find.Execute) Then
              .Collapse wdCollapseEnd
              .MoveEndUntil cset:=Chr(13)
              .Collapse wdCollapseEnd
          End If
      End With
      End Sub
      

      HTH,

    • in reply to: Use Find without selecting (2002) #831229

      Hi Jeanie,

      I think this is what you’re looking for:

      Sub MoveToNextHeading()
      With Selection
          With .Find
              .ClearFormatting
              .Text = "^p^p"
              .Replacement.Text = ""
              .Forward = True
              .Wrap = wdFindAsk
              .Format = False
              .MatchCase = False
              .MatchWholeWord = False
              .MatchWildcards = False
              .MatchSoundsLike = False
              .MatchAllWordForms = False
          End With
          
          If (.Find.Execute) Then
              .Collapse wdCollapseEnd
              .MoveEndUntil cset:=Chr(13)
              .Collapse wdCollapseEnd
          End If
      End With
      End Sub
      

      HTH,

    • in reply to: Change date field in normal.dot (Word 2002 SP-2) #828633

      Hi Clark,

      If you change the name of the macro you recorded to “InsertDateField” it will run when the “InsertDate” toolbar button is pressed.

    • in reply to: Change date field in normal.dot (Word 2002 SP-2) #828634

      Hi Clark,

      If you change the name of the macro you recorded to “InsertDateField” it will run when the “InsertDate” toolbar button is pressed.

    • in reply to: Macro to Delete CharChar styles (Word 2002) #827986

      Hi all,

      Sorry to keep resurrecting this thread, but I had a Eureka moment today, and needed to share. I was trying to figure out how to kill the Char style, but keep the formatting, and then it hit me:

      Dim rng as Range
      Dim f as Font
      ...
      Set f = rng.Font.Duplicate
      rng.Font.Reset
      rng.Font = f
      ...
      

      That removes the character style, then reapplies all the style’s formatting.

      I had this split into three separate macros, but thought a single subroutine would be (slightly) easier to follow. If anyone’s interested in the separated (and better commented versions), I can post that as well.

      The attached macro:

      (1). Deletes any “Char Char” styles
      (2). Retains the character formatting of the text that had the “Char Char” style applied
      (3). Retains any style aliases
      (4). Allows for document styles that begin with “Char”

      Another issue I’ve encountered (it usually shows up when the document’s opened in Word 2000) is that often there will be a paragraph style with “Char Char” in the name, and the original style without the “Char Char” will still be in the document. That raises an error when trying to rename the “Char Char” style. This macro takes care of that, applying the “Char-free” pun style to any text that has the “Char Char” paragraph style applied, and then deletes that style.

      I tried to make something that would work in Word 2000/97, which don’t support the LinkStyle property, but I couldn’t do it. There’s a line in the code:

      sty.LinkStyle = wdStyleNormal

      that should be commented out on Word 2000 (or you’ll get a compilation error).

      I would appreciate any feedback.

    • in reply to: Macro to Delete CharChar styles (Word 2002) #827987

      Hi all,

      Sorry to keep resurrecting this thread, but I had a Eureka moment today, and needed to share. I was trying to figure out how to kill the Char style, but keep the formatting, and then it hit me:

      Dim rng as Range
      Dim f as Font
      ...
      Set f = rng.Font.Duplicate
      rng.Font.Reset
      rng.Font = f
      ...
      

      That removes the character style, then reapplies all the style’s formatting.

      I had this split into three separate macros, but thought a single subroutine would be (slightly) easier to follow. If anyone’s interested in the separated (and better commented versions), I can post that as well.

      The attached macro:

      (1). Deletes any “Char Char” styles
      (2). Retains the character formatting of the text that had the “Char Char” style applied
      (3). Retains any style aliases
      (4). Allows for document styles that begin with “Char”

      Another issue I’ve encountered (it usually shows up when the document’s opened in Word 2000) is that often there will be a paragraph style with “Char Char” in the name, and the original style without the “Char Char” will still be in the document. That raises an error when trying to rename the “Char Char” style. This macro takes care of that, applying the “Char-free” pun style to any text that has the “Char Char” paragraph style applied, and then deletes that style.

      I tried to make something that would work in Word 2000/97, which don’t support the LinkStyle property, but I couldn’t do it. There’s a line in the code:

      sty.LinkStyle = wdStyleNormal

      that should be commented out on Word 2000 (or you’ll get a compilation error).

      I would appreciate any feedback.

    • in reply to: Different way to delete style aliases (Word 2000+) #828056

      Here’s the VB6 string functions written in VB5 if you’re interested. These are much better than the ones in the knowledgebase.

      http://www.freevbcode.com/ShowCode.asp?ID=17%5B/url%5D

    • in reply to: Different way to delete style aliases (Word 2000+) #828057

      Here’s the VB6 string functions written in VB5 if you’re interested. These are much better than the ones in the knowledgebase.

      http://www.freevbcode.com/ShowCode.asp?ID=17%5B/url%5D

    • in reply to: Getting Footnote Reference (Word 2000+) #828053

      Hi Andrew,

      Just tried that, but I keep getting that non-printing character (ASCII value 2). brickwall

      I was trying to write a macro that would generate a 2-column table of footnotes, with the paragraph containing the reference (and including the reference) in one column, and the footnote text in the other.

      Thanks for your help!

    • in reply to: Getting Footnote Reference (Word 2000+) #828052

      Hi Andrew,

      Just tried that, but I keep getting that non-printing character (ASCII value 2). brickwall

      I was trying to write a macro that would generate a 2-column table of footnotes, with the paragraph containing the reference (and including the reference) in one column, and the footnote text in the other.

      Thanks for your help!

    Viewing 15 replies - 541 through 555 (of 578 total)