Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-02-2018, 09:43 PM
gmayor's Avatar
gmayor gmayor is offline Macros from this Forum will not run. Windows 10 Macros from this Forum will not run. Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I have again tested the code (repeated below) and it does what it is supposed to do and the completion message (not part of the original) works where it is now placed.

If the macro doesn't do anything, it is likely to be that the criteria set in the code does not match what is in the document. Post a sample document in which it does not work.

Quote:
Originally Posted by jeffreybrown View Post
not sure why you even need Exit Sub as there is nothing left to do or skip.
It's a personal programming foible, that I use will all my code, and which is primarily used in conjunction with error handling routines, though in this instance there is no such routine.
Code:
Sub Delete_Underscores()
' 'Graham Mayor - http://www.gmayor.com - Last updated - 03 Oct 2018
'
' Delete_Underscores Macro
' Will delete all underscores in Document except in Mail addresses (& hyperlinks ??)
' This version RETYPED from published Macro because of difficulties with MS Office site.
' CALL with ALT + U (for Underscore)

Dim oRng As Range
Dim oWord As Range

    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:="_")
            Set oWord = oRng.Duplicate
            If oWord.Words(1).Start <> ActiveDocument.Range.Start Then
                oWord.MoveStartUntil Chr(32), wdBackward
                oWord.MoveEndUntil Chr(32) & Chr(13)
                If InStr(1, oWord.Text, "@") = 0 Then oRng.Text = " "
            End If
            oRng.Collapse 0
        Loop
    End With
    MsgBox "Yes, it ran."    'Added.
lbl_Exit:
    Set oRng = Nothing
    Set oWord = Nothing
    Exit Sub
End Sub

__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #2  
Old 10-02-2018, 09:47 PM
macropod's Avatar
macropod macropod is offline Macros from this Forum will not run. Windows 7 64bit Macros from this Forum will not run. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by gmayor View Post
If the macro doesn't do anything, it is likely to be that the criteria set in the code does not match what is in the document. Post a sample document in which it does not work.
Or maybe macro support hasn't been installed...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-03-2018, 12:28 AM
gmayor's Avatar
gmayor gmayor is offline Macros from this Forum will not run. Windows 10 Macros from this Forum will not run. Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Quote:
Originally Posted by macropod View Post
Or maybe macro support hasn't been installed...
Or that
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #4  
Old 10-03-2018, 03:19 AM
Seatonian Seatonian is offline Macros from this Forum will not run. Windows 7 64bit Macros from this Forum will not run. Office 2010 64bit
Novice
Macros from this Forum will not run.
 
Join Date: Sep 2018
Posts: 7
Seatonian is on a distinguished road
Default

My thanks to contributors Jeffrey Brown, Macropod and Graham Mayor, luminaries all from across the world.

Moving the Msg Box higher in the Code has enabled it to work (and Macropod's MsgBox "!" also works.) But this is during compilation. There is still no activity (i.e. deletions) on the TestBed Text a copy of which is attached below. It deliberately has no Title.

The TestBed is just random text which, for this Project, has had Underscoring Formatting of graded complexity added. I use many macros now as I am unable to use the mouse with any accuracy. Please note that coloured or "weighted" Underscoring are not displayed within this Forum. Nor is Double Underscoring.

I am not sure what is meant by "Macro Support". And since all other macros work properly, does that not answer the question of whether it is installed? Please tell me where I can check this and when it is invoked. Thank you all for your kind contributions.



TEST.

On the Insert tab, the galleries include items that are designed to coordinate with the overall look of your document. When you create pictures, charts, or diagrams, they also coordinate with your current document look. You can easily change the formatting of selected text in the document text by choosing a look for the selected text from the Quick Styles gallery on the Home tab. You can use these galleries to insert tables, headers, footers, lists, cover pages, and other document building blocks.You can easily change the formatting of selected text in the documenttext by choosing a look for the selected text from the Quick Styles gallery on the Home tab.
END OF TEST.




Reply With Quote
  #5  
Old 10-03-2018, 04:08 AM
jeffreybrown jeffreybrown is offline Macros from this Forum will not run. Windows Vista Macros from this Forum will not run. Office 2007
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Hi Graham,

Quote:
It's a personal programming foible, that I use will all my code, and which is primarily used in conjunction with error handling routines, though in this instance there is no such routine.
I surely wasn't intending to say it shouldn't be there, just pointing out I didn't understand it's use. Please accept my apology if it came across as a jab, because it wasn't.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a sub-Forum for Office for Mac? IvanH Office 1 02-20-2014 11:31 PM
Macros from this Forum will not run. MS Windows forum? Joan64 Office 2 07-01-2013 10:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:26 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