• WSAndrew77

    WSAndrew77

    @wsandrew77

    Viewing 15 replies - 526 through 540 (of 578 total)
    Author
    Replies
    • in reply to: Turn off OVR (Word 2000 OVR) #837208

      Hello,

      If you want to actually disable the command (so that even double-clicking OVR won’t turn it on), put an empty macro named “Overtype” in your Normal.dot template:

      Sub Overtype
      ' do nothing
      End Sub
      

      HTH

    • in reply to: Turn off OVR (Word 2000 OVR) #837207

      Hello,

      If you want to actually disable the command (so that even double-clicking OVR won’t turn it on), put an empty macro named “Overtype” in your Normal.dot template:

      Sub Overtype
      ' do nothing
      End Sub
      

      HTH

    • in reply to: Store Numbers in Table (VBA Word 97 / 2000) #836455

      How about using a config file?

      [&Caption Here]
      level=1
      Position=10
      Macro=SomeMacro
      Divider=TRUE
      FaceID=1234
      
      [&Another Caption]
      level=2
      Position=9
      Macro=SomeOtherMacro
      Divider=FALSE
      FaceID=444
      

      You access the values with the System.PrivateProfileString method (more info in the help files on that). That way you could also edit the entries manually with a text editor.

    • in reply to: Store Numbers in Table (VBA Word 97 / 2000) #836456

      How about using a config file?

      [&Caption Here]
      level=1
      Position=10
      Macro=SomeMacro
      Divider=TRUE
      FaceID=1234
      
      [&Another Caption]
      level=2
      Position=9
      Macro=SomeOtherMacro
      Divider=FALSE
      FaceID=444
      

      You access the values with the System.PrivateProfileString method (more info in the help files on that). That way you could also edit the entries manually with a text editor.

    • in reply to: Programmatically Add Image to RTF (2000) #836257

      From “RTF: Pocket Guide,” published by (who else) O’Reilly & Associates:

      [indent]


      Embedding Images
      In an ideal world, RTF would allow you to insert a picture into a document by simply dropping a hex-encoded GIF, JPEG, or PNG file into your RTF code. But RTF doesn’t do things that way. The RTF specification, on the subject of pictures, explains a {pict…} construct that contains picture data (typically as a long series of hexadecimal digits). But the picture data encoded in the {pict…} construct is in a binary format that can’t be converted to easily from a conventional image format (i.e., GIF, JPEG, or PNG).
      If you want to insert images in an RTF file, you have three options.

      The first option is to give up and do without the image. In many cases, the image isn’t necessary (as with a company logo on an invoice document).

      The second option is to produce the binary encoding of the image by copying it out of an RTF file generated by a word processor. So if you want to insert a logo in an invoice that you’re autogenerating as RTF, you could start AbiWord (for example), start a new blank file, insert a picture from disk, save the file as .rtf, and then open the .rtf file in a text editor. For example, inserting a 2 x 2 blue dot in AbiWord produces an RTF file that ends like this:

      pardplainltrpars15{*shppict
      {pictpngblippicw2pich2picwgoal28pichgoal28
      bliptag10000{*blipuid 00000000000000000000000000002710}
      89504e470d0a1a0a0000000d4948445200000002000000020403000000809810
      1700000030504c54450000008000000080008080000000808000800080808080
      80c0c0c0ff000000ff00ffff000000ffff00ff00ffffffffff7b1fb1c4000000
      0c49444154789c6338c3700600033401997bc924ce0000000049454e44ae4260
      82}}{f4fs24lang1033{*listtag0}}}

      This image could be copied into other documents by copying the {pict…} group and inserting it directly into another document as needed. (Note that it must be copied from {pict up to the next matching }, not just the next }. Otherwise, you end up stopping prematurely, at the end of the third line above.)
      The third way to insert images in an RTF file is to use this quite nonstandard code to have the word processor insert an arbitrary external image file into the document:

      {fieldfldedit{*fldinst { INCLUDEPICTURE  d
       "PicturePath"
       * MERGEFORMATINET }}{fldrslt {  }}}

      In the PicturePath, path separators must either be a forward slash, like so:

      {fieldfldedit{*fldinst { INCLUDEPICTURE  d
       "C:/stuff/Group_x/images/alaska_map.gif"
       * MERGEFORMATINET }}{fldrslt {  }}}

      or must be a double-backslash, escaped (either as ‘5c’5c or as ), like so:

      {fieldfldedit{*fldinst { INCLUDEPICTURE  d
       "C:'5c'5cstuff'5c'5cGroup_x'5c'5cimages'5c'5calaska_map.gif"
       * MERGEFORMATINET }}{fldrslt {  }}}

      or:

      {fieldfldedit{*fldinst { INCLUDEPICTURE  d
       "C:stuffGroup_ximagesalaska_map.gif"
       * MERGEFORMATINET }}{fldrslt {  }}}

      At time of this writing, this whole image-via-field construct seems to be particular to MSWord versions, beginning with Word 2000. Other word processors either just ignore the construct (as AbiWord, Wordpad, and others do), or they throw an error (like MSWord Viewer 97, which replaces the image with the text “Error! Unknown switch argument”).
      You can control exact positioning of an image on the page by simply making it the content of an exact-positioned paragraph, as discussed at the end of the “Basic RTF Syntax” section. For example, this image’s top-left corner starts 2,160 twips across and 3,600 twips down from the page’s top-left corner:

      {pard pvpgphpg posx2160 posy3600
      field...} or {pict...}
      par}

      [/indent]

      Sounds like Option 2 might work for you.

      BTW, I highly recommend that book if you regulary work in RTF. (Hey, it’s only $12.95)

      HTH!

    • in reply to: Programmatically Add Image to RTF (2000) #836258

      From “RTF: Pocket Guide,” published by (who else) O’Reilly & Associates:

      [indent]


      Embedding Images
      In an ideal world, RTF would allow you to insert a picture into a document by simply dropping a hex-encoded GIF, JPEG, or PNG file into your RTF code. But RTF doesn’t do things that way. The RTF specification, on the subject of pictures, explains a {pict…} construct that contains picture data (typically as a long series of hexadecimal digits). But the picture data encoded in the {pict…} construct is in a binary format that can’t be converted to easily from a conventional image format (i.e., GIF, JPEG, or PNG).
      If you want to insert images in an RTF file, you have three options.

      The first option is to give up and do without the image. In many cases, the image isn’t necessary (as with a company logo on an invoice document).

      The second option is to produce the binary encoding of the image by copying it out of an RTF file generated by a word processor. So if you want to insert a logo in an invoice that you’re autogenerating as RTF, you could start AbiWord (for example), start a new blank file, insert a picture from disk, save the file as .rtf, and then open the .rtf file in a text editor. For example, inserting a 2 x 2 blue dot in AbiWord produces an RTF file that ends like this:

      pardplainltrpars15{*shppict
      {pictpngblippicw2pich2picwgoal28pichgoal28
      bliptag10000{*blipuid 00000000000000000000000000002710}
      89504e470d0a1a0a0000000d4948445200000002000000020403000000809810
      1700000030504c54450000008000000080008080000000808000800080808080
      80c0c0c0ff000000ff00ffff000000ffff00ff00ffffffffff7b1fb1c4000000
      0c49444154789c6338c3700600033401997bc924ce0000000049454e44ae4260
      82}}{f4fs24lang1033{*listtag0}}}

      This image could be copied into other documents by copying the {pict…} group and inserting it directly into another document as needed. (Note that it must be copied from {pict up to the next matching }, not just the next }. Otherwise, you end up stopping prematurely, at the end of the third line above.)
      The third way to insert images in an RTF file is to use this quite nonstandard code to have the word processor insert an arbitrary external image file into the document:

      {fieldfldedit{*fldinst { INCLUDEPICTURE  d
       "PicturePath"
       * MERGEFORMATINET }}{fldrslt {  }}}

      In the PicturePath, path separators must either be a forward slash, like so:

      {fieldfldedit{*fldinst { INCLUDEPICTURE  d
       "C:/stuff/Group_x/images/alaska_map.gif"
       * MERGEFORMATINET }}{fldrslt {  }}}

      or must be a double-backslash, escaped (either as ‘5c’5c or as ), like so:

      {fieldfldedit{*fldinst { INCLUDEPICTURE  d
       "C:'5c'5cstuff'5c'5cGroup_x'5c'5cimages'5c'5calaska_map.gif"
       * MERGEFORMATINET }}{fldrslt {  }}}

      or:

      {fieldfldedit{*fldinst { INCLUDEPICTURE  d
       "C:stuffGroup_ximagesalaska_map.gif"
       * MERGEFORMATINET }}{fldrslt {  }}}

      At time of this writing, this whole image-via-field construct seems to be particular to MSWord versions, beginning with Word 2000. Other word processors either just ignore the construct (as AbiWord, Wordpad, and others do), or they throw an error (like MSWord Viewer 97, which replaces the image with the text “Error! Unknown switch argument”).
      You can control exact positioning of an image on the page by simply making it the content of an exact-positioned paragraph, as discussed at the end of the “Basic RTF Syntax” section. For example, this image’s top-left corner starts 2,160 twips across and 3,600 twips down from the page’s top-left corner:

      {pard pvpgphpg posx2160 posy3600
      field...} or {pict...}
      par}

      [/indent]

      Sounds like Option 2 might work for you.

      BTW, I highly recommend that book if you regulary work in RTF. (Hey, it’s only $12.95)

      HTH!

    • in reply to: Shift Table Cells (2002) #835880

      With the cell selected, when you go to Table -> Delete -> Cells, you should be prompted to choose how to accommodate the change. In your case, choose “Shift Cells Left”

      HTH,

    • in reply to: Shift Table Cells (2002) #835881

      With the cell selected, when you go to Table -> Delete -> Cells, you should be prompted to choose how to accommodate the change. In your case, choose “Shift Cells Left”

      HTH,

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

      Hi Gary,

      Thanks so much for taking this code for a test drive. I definitely appreciate the feedback. Any chance you could post a (blank) copy of one of those nasty specimens you talked about? I’d love to be able to have something really “bad” to test with while I experiment with your suggestions. In the meantime, I modifed some documents to include styles with names like the ones you encountered. It looks like it’s not an issue of built ins, it’s just inadequate string processing on my part. I never tested with numerals appended to the “char” (Char1, char2, etc.).

      The snippet below replaces the more elegant, but inadequate Replace call with some cumbersome but effective good old-fashioned string functions. What I wouldn’t give for built-in regular expressions and variable interpolation!

      As for retaining the character formatting, I agree with you on its questionable necessity, but did want to offer it at least as an option.

      ' Replace this line:
      'sStyleReName = Replace(sStyleName, " Char", "")
      '
      ' with this block (new variables declared here for easier reading)
      '
                      Dim k As Integer
                      Dim lPos As Long
                      Dim var As Variant
                      var = Split(sStyleName, ",")
                      For k = 0 To UBound(var)
                          lPos = InStr(var(k), " Char")
                          If lPos  0 Then
                              var(k) = Left(var(k), lPos - 1)
                          End If
                      Next k
                      sStyleReName = Join(var, ",")
      

      A more compact, but less readable version without using the lPos variable would be:

      ...
      For k = 0 to UBound(var)
          If InStr(var(k), " Char")  0 Then var(k) = Left(var(k), (InStr(var(k), " Char")) - 1)
      Next k
      ...
      

      As an aside for anyone interested, note that even if you’ve set your array base explicitly to 1, variant arrays populated with the Split function are always 0-based. Ditto for using the Array function.

      Thanks again, Gary!

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

      Hi Gary,

      Thanks so much for taking this code for a test drive. I definitely appreciate the feedback. Any chance you could post a (blank) copy of one of those nasty specimens you talked about? I’d love to be able to have something really “bad” to test with while I experiment with your suggestions. In the meantime, I modifed some documents to include styles with names like the ones you encountered. It looks like it’s not an issue of built ins, it’s just inadequate string processing on my part. I never tested with numerals appended to the “char” (Char1, char2, etc.).

      The snippet below replaces the more elegant, but inadequate Replace call with some cumbersome but effective good old-fashioned string functions. What I wouldn’t give for built-in regular expressions and variable interpolation!

      As for retaining the character formatting, I agree with you on its questionable necessity, but did want to offer it at least as an option.

      ' Replace this line:
      'sStyleReName = Replace(sStyleName, " Char", "")
      '
      ' with this block (new variables declared here for easier reading)
      '
                      Dim k As Integer
                      Dim lPos As Long
                      Dim var As Variant
                      var = Split(sStyleName, ",")
                      For k = 0 To UBound(var)
                          lPos = InStr(var(k), " Char")
                          If lPos  0 Then
                              var(k) = Left(var(k), lPos - 1)
                          End If
                      Next k
                      sStyleReName = Join(var, ",")
      

      A more compact, but less readable version without using the lPos variable would be:

      ...
      For k = 0 to UBound(var)
          If InStr(var(k), " Char")  0 Then var(k) = Left(var(k), (InStr(var(k), " Char")) - 1)
      Next k
      ...
      

      As an aside for anyone interested, note that even if you’ve set your array base explicitly to 1, variant arrays populated with the Split function are always 0-based. Ditto for using the Array function.

      Thanks again, Gary!

    • in reply to: Macro to count tabs in a paragraph (2002) #834192

      (Edited by Andrew77 on 29-May-04 03:46. )

      Hello,

      I’m sure there are other ways, but here’s a quick and dirty method that may get you started.

      Sub ProcessParasWithTabs
      Dim iTabs As Integer
      Dim rng As Range
      Dim para As Paragraph
      For Each para In ActiveDocument.Paragraphs
          iTabs = 0
          Set rng = para.Range
          Do While InStr(rng.Text, Chr(9))  0
              iTabs = iTabs + 1
              rng.MoveStartUntil cset:=Chr(9), Count:=Len(rng.Text)
              rng.MoveStart unit:=wdCharacter, Count:=1
          Loop
          If iTabs = 3 Then
              ' Do stuff here
          ElseIf iTabs = 4 Then
              ' do stuff here
          End If
      Next para
      End Sub
      

      HTH

      Added: A more general function to get the count of any character in a paragraph would be:

      Function CharacterCountInPara(para As Paragraph, ByVal char As String) As Integer
      Dim rng As Range
      Dim iCount As Integer
      Set rng = para.Range
      iCount = 0
      char = Left(char, 1)
      Do While InStr(rng.Text, char)  0
          iCount = iCount + 1
          rng.MoveStartUntil cset:=char, Count:=Len(rng.Text)
          rng.MoveStart unit:=wdCharacter, Count:=1
      Loop
      CharacterCountInPara = iCount
      Set rng = Nothing
      End Function
      

      Comments welcome.

    • in reply to: Macro to count tabs in a paragraph (2002) #834193

      (Edited by Andrew77 on 29-May-04 03:46. )

      Hello,

      I’m sure there are other ways, but here’s a quick and dirty method that may get you started.

      Sub ProcessParasWithTabs
      Dim iTabs As Integer
      Dim rng As Range
      Dim para As Paragraph
      For Each para In ActiveDocument.Paragraphs
          iTabs = 0
          Set rng = para.Range
          Do While InStr(rng.Text, Chr(9))  0
              iTabs = iTabs + 1
              rng.MoveStartUntil cset:=Chr(9), Count:=Len(rng.Text)
              rng.MoveStart unit:=wdCharacter, Count:=1
          Loop
          If iTabs = 3 Then
              ' Do stuff here
          ElseIf iTabs = 4 Then
              ' do stuff here
          End If
      Next para
      End Sub
      

      HTH

      Added: A more general function to get the count of any character in a paragraph would be:

      Function CharacterCountInPara(para As Paragraph, ByVal char As String) As Integer
      Dim rng As Range
      Dim iCount As Integer
      Set rng = para.Range
      iCount = 0
      char = Left(char, 1)
      Do While InStr(rng.Text, char)  0
          iCount = iCount + 1
          rng.MoveStartUntil cset:=char, Count:=Len(rng.Text)
          rng.MoveStart unit:=wdCharacter, Count:=1
      Loop
      CharacterCountInPara = iCount
      Set rng = Nothing
      End Function
      

      Comments welcome.

    • in reply to: force ‘text only’ (word xp) #833586
      1. Go to Tools -> Customize
      2. Select the Toolbars tab
      3. Check the box marked “Shortcut menus”
        A small toolbar titled “Shortcut menus” should appear, generally near the top left of your screen. Don’t close the Customize dialog yet.
      4. Press the “Text” button on the “Shortcut Menu” toolbar
      5. Select the “Text” submenu on the Text menu
      6. Now go back to the Customize dialog, and go to the Commands tab.
      7. In “Categories” select “Macros”
      8. In commands, find your new macro
      9. Click and drag the macro to the text shortcut menu
        You can also drag it to any other shortcut menus you’d like it on. You can also remove the “regular” paste from the shortcut menu.
      10. When you’re finished, just close the Customize dialog; the Shortcut menus toolbar will close automatically.

      HTH,

    • in reply to: force ‘text only’ (word xp) #833587
      1. Go to Tools -> Customize
      2. Select the Toolbars tab
      3. Check the box marked “Shortcut menus”
        A small toolbar titled “Shortcut menus” should appear, generally near the top left of your screen. Don’t close the Customize dialog yet.
      4. Press the “Text” button on the “Shortcut Menu” toolbar
      5. Select the “Text” submenu on the Text menu
      6. Now go back to the Customize dialog, and go to the Commands tab.
      7. In “Categories” select “Macros”
      8. In commands, find your new macro
      9. Click and drag the macro to the text shortcut menu
        You can also drag it to any other shortcut menus you’d like it on. You can also remove the “regular” paste from the shortcut menu.
      10. When you’re finished, just close the Customize dialog; the Shortcut menus toolbar will close automatically.

      HTH,

    • in reply to: Stopping Task Pane from Opening (2003) #833469

      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

    Viewing 15 replies - 526 through 540 (of 578 total)