Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-17-2023, 10:00 AM
RobiNew RobiNew is offline Perfect macro not working when its code is inserted in larger macro Windows 10 Perfect macro not working when its code is inserted in larger macro Office 2016
Competent Performer
Perfect macro not working when its code is inserted in larger macro
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Question Perfect macro not working when its code is inserted in larger macro

I devised the macro here below to apply Superscript to the last character of a five digit string. It works perfectly, but when I insert the code in a larger macro the last character remains intact. Can someone help? Thanks!

Code:
Dim oRng As Range, iType As Integer
  For iType = 1 To 2
    Set oRng = ActiveDocument.StoryRanges(iType)
    With oRng.Find
      .ClearFormatting
      .Text = "^#^#^#^#^#"
      While .Execute
        oRng.Collapse wdCollapseEnd
        oRng.MoveStart Unit:=wdCharacter, Count:=-1
        oRng.Font.Superscript = True
      Wend
    End With
  Next iType

Reply With Quote
  #2  
Old 10-17-2023, 11:30 AM
vivka vivka is offline Perfect macro not working when its code is inserted in larger macro Windows 7 64bit Perfect macro not working when its code is inserted in larger macro Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

Hi, RobiNew! What's the sense of improving a perfect macro? Could you post the macro that causes the problem?
Reply With Quote
  #3  
Old 10-18-2023, 12:13 AM
RobiNew RobiNew is offline Perfect macro not working when its code is inserted in larger macro Windows 10 Perfect macro not working when its code is inserted in larger macro Office 2016
Competent Performer
Perfect macro not working when its code is inserted in larger macro
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default

High, Vivka! Unfortunately I cannot post the large macro, because it contains sensitive data. The mystery remains, but I modified the large macro so that now it doesn't need the code I posted above. Thanks anyway!
Reply With Quote
  #4  
Old 10-18-2023, 03:19 AM
vivka vivka is offline Perfect macro not working when its code is inserted in larger macro Windows 7 64bit Perfect macro not working when its code is inserted in larger macro Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

It's nice you managed to find a solution!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to NOT RUN an (autosave) macro within a macro Kain Word 2 08-04-2020 06:32 AM
Perfect macro not working when its code is inserted in larger macro Inserted Image in Form to show larger image on Click tasneemj Word 15 02-11-2018 04:12 PM
Perfect macro not working when its code is inserted in larger macro VBA Macro code help get4hari Excel Programming 8 09-26-2015 10:33 PM
Perfect macro not working when its code is inserted in larger macro Looking Again for Another Code/Macro rsrasc Word VBA 5 11-16-2014 05:47 AM
Perfect macro not working when its code is inserted in larger macro Inserted AutoText table incorrectly formatted - unless macro paused! Smallweed Word VBA 4 01-16-2014 03:15 PM

Other Forums: Access Forums

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


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