Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-03-2023, 11:27 AM
aj92 aj92 is offline MS Word Macro - Infinite Spinning Wheel - Thanks Maxey! Windows 11 MS Word Macro - Infinite Spinning Wheel - Thanks Maxey! Office 2021
Novice
MS Word Macro - Infinite Spinning Wheel - Thanks Maxey!
 
Join Date: Nov 2023
Posts: 9
aj92 is on a distinguished road
Default MS Word Macro - Infinite Spinning Wheel - Thanks Maxey!

Greg Maxey was kind enough to provide the last portion of code that I've since modified for the reasons stated below. Thanks Greg if you see this! So right now, I have this code for a VBA macro in the Normal>Module section of the VBA editor named "CntCntrls" that does the following:


-allows me to add rich text content control
-allows me to add a tag/title to the rich text content control -allows me to edit an existing tag/title to a rich text content control
-allows me to delete any rich text content control that does not have "Me" as the tag. This will also delete the page of the affected rich text content control so that there isn't excess space from the deleted rich text content controls


--


The problem I'm having is that I'm getting a spinning wheel that loads infinitely but never actually runs the macro despite the document being only 10 pages that I'm using for testing.


Is there something you guys can pick up on that may be potentially causing this issue?


--


Some potentially useful specs: -MacOs Monterey 12.6.8 on 2021 M1 Macbook pro -Office Home & Business 2021 License


--


Sub A_A_AddRichTextControl()
Dim rngSelection As Range

Set rngSelection = Selection.Range
ActiveDocument.ContentControls.Add Type:=wdContentControlRichText, Range:=rngSelection
End Sub


Sub A_B_EditTagAndTitleOfRichTextControl()
Dim cc As ContentControl
Dim newTag As String

If Selection.Range.ContentControls.Count = 1 Then
Set cc = Selection.Range.ContentControls(1)

' Prompt for new tag
newTag = InputBox("Enter new tag for the rich text content control:", "New Tag")

' Set new tag and title
If newTag <> "" Then
cc.tag = newTag
cc.Title = newTag ' Set title equal to the tag
End If
Else
MsgBox "Select a single rich text content control to edit tag and title.", vbExclamation
End If
End Sub


Sub A_C_EditContentControlTagAndTitle()
Dim cc As ContentControl
Dim newTag As String

' Check if the selection contains a content control
If Selection.Range.ContentControls.Count > 0 Then
' Store a reference to the first content control in the selection
Set cc = Selection.Range.ContentControls(1)

' Prompt the user for new tag and title values
newTag = InputBox("Enter the content control property tag:", "Edit Tag", cc.tag)

' Update the tag and title
cc.tag = newTag
cc.Title = newTag

' Optional: Refresh the content control to apply changes
cc.LockContentControl = True
cc.LockContentControl = False
Else
MsgBox "Please select a content control before running this macro.", vbExclamation
End If
End Sub


Sub B_A_RemoveRT_ExceptMe()

Dim oCC As ContentControl


Dim arrTagParts() As String
Dim lngIndex As Long
Dim bDelete As Boolean
Dim oPage As Range

For Each oCC In ActiveDocument.ContentControls
bDelete = True
If oCC.Type = 0 Then 'wdContentControlText
arrTagParts = Split(oCC.tag, " ")
For lngIndex = 0 To UBound(arrTagParts)
If arrTagParts(lngIndex) = "Me" Then
bDelete = False
Exit For
End If
Next lngIndex
If bDelete Then
' Get the page range of the content control
Set oPage = oCC.Range.GoTo(wdGoToPage, wdGoToAbsolute, oCC.Range.Information(wdActiveEndPageNumber))
' Delete the content control
oCC.Delete True
' Delete the entire page
oPage.Delete
End If
End If
Next oCC
lbl_Exit:
Exit Sub
End Sub
Reply With Quote
 

Tags
macro, ms-word, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with G Maxey's Content Control Custom Event Irimi-Ai Word VBA 1 11-19-2020 02:20 PM
MS Word Macro - Infinite Spinning Wheel - Thanks Maxey! Infinite loops occurring in find and replace functions in word macro Thefirstfish` Word VBA 5 04-06-2017 07:18 PM
MACRO in infinite loop when it encounters user defined figure label photoval Word VBA 3 02-02-2016 08:26 PM
POWER POINT 97-2003 - I need to make a spinning wheel PANTECH PowerPoint 0 05-29-2014 08:16 AM
MS Word Macro - Infinite Spinning Wheel - Thanks Maxey! wildly flashing insertion point with spinning wheel joannetk Word 4 03-10-2011 04:26 AM

Other Forums: Access Forums

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