Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-01-2019, 04:52 AM
Guessed's Avatar
Guessed Guessed is offline URL formatting + a new question Windows 10 URL formatting + a new question Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default


I haven't got your document so I'm not able to test but this is a tidier version of what you had working. I'm still not sure what the loop through the Para's is supposed to achieve but if you are happy with it then that should be fine.
Code:
Sub TopiaFormat()
  Dim Para As Paragraph, Rng As Range, HLnk As Hyperlink
  
  ActiveDocument.ConvertNumbersToText

  For Each Para In ActiveDocument.Range.Paragraphs
    With Para.Range
      If .Text Like "?" & vbTab & "*" Then
        Set Rng = .Duplicate
        With Rng
          .End = .Start + 2
          .Text = Chr(149) & vbTab
        End With
      End If
    End With
  Next

  With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Wrap = wdFindContinue
    .Forward = True
    
    .Text = "^0233"
    .Replacement.Text = " - "
    .Execute Replace:=wdReplaceAll
    
    .Text = "ï"
    .Replacement.Text = "[*]"
    .Execute Replace:=wdReplaceAll
    
    .Text = "[*]^w"
    .Execute Replace:=wdReplaceAll
    
    .Text = "^p^p"
    .Replacement.Text = "^p^p^p"
    .Execute Replace:=wdReplaceAll
  End With

  For Each HLnk In ActiveDocument.Hyperlinks
    HLnk.Range.InsertAfter "]"
    HLnk.Range.InsertBefore "[>" & HLnk.Address & "|"
    HLnk.Delete
  Next
  
  ActiveDocument.Range.ClearFormatting
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #2  
Old 02-01-2019, 05:17 AM
mroatman mroatman is offline URL formatting + a new question Mac OS X URL formatting + a new question Office 2019
Novice
URL formatting + a new question
 
Join Date: Jan 2019
Location: Tallinn, Estonia
Posts: 9
mroatman is on a distinguished road
Default

Thanks Andrew. Your revised code is indeed much cleaner, but it wouldn't execute properly for me (error message attached). This may be because I'm running a different version of Word on a Mac. For reference, my test document is in Post 3.

Quote:
Originally Posted by Guessed View Post
I'm still not sure what the loop through the Para's is supposed to achieve
I believe this was to get MS Word to treat the automated bullets as regular text, as otherwise they are handled very differently for automated (vs manual) lists. Macropod states:

Quote:
Originally Posted by macropod View Post
Before you can do anything with those particular bullets, you'll need to convert them to manual bullets - right now, they're automatic bullets. Try:
Code:
Sub ReplaceBullets()
Dim Para As Paragraph, Rng As Range
For Each Para In ActiveDocument.Range.Paragraphs
  With Para.Range
    If .Text Like "?" & vbTab & "*" Then
      Set Rng = .Duplicate
      With Rng
        .End = .Start + 2
        .Text = vbNullString
        .InsertBefore Chr(149) & vbTab
      End With
    End If
  End With
Next
End Sub
Somehow, it worked for the other poster in that thread as well, but I can't tell you why.

Thanks again for all your help in getting me here.
Attached Images
File Type: png Screen Shot 2019-02-01 at 14.09.20.png (25.4 KB, 17 views)
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing a comment with underline or other formatting (or adding that formatting to commented text) paulkaye Word 4 05-16-2016 05:38 AM
URL formatting + a new question The Logic Behind Apply Formatting of Surrounding Text in Reveal Formatting Pane Instructor Mark Word 4 04-06-2016 01:32 PM
URL formatting + a new question How to do a find and replace on formatting for partial word formatting. BrianSvanvik Word 2 09-04-2015 01:20 PM
Find and Replace, Formatting, Formatting Formula kjxavier Word 1 07-04-2014 09:11 AM
Formatting contents after Tab of continuous lines or formatting specific area of word pawii Word 1 05-12-2014 05:24 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:25 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft