|
|
Thread Tools | Display Modes |
#1
|
||||
|
||||
Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup
Hello Pros,
I was sure I did a good job, but if my document has more group of textbox, it ignores the Selected textbox group and goes to the next BUT if I have the same TextBox Group, copied a few time in an empty document, it takes it???? HTML Code:
Sub Graph_CONVERT_1_TxtBox_to_WrapSquare_and_Ungroup() 'based on ungroup = web link https://stackoverflow.com/questions/51141788/word-macro-to-ungroup-text-boxes 'created by me, which playing, with the scripts 2023-06-01 Dim xNmbr As Integer With ActiveDocument 'For xNmbr = .Shapes.Count To 1 Step -1 (changed this from all to set (1) 'Set thisshape = .Shapes(xNmbr) Set thisshape = .Shapes(1) .Shapes(1).Select With thisshape.WrapFormat .Type = wdWrapSquare If thisshape.Type = msoGroup Then thisshape.Ungroup End With ' Next End With On Error GoTo 0 Set xNbre = Nothing End Sub Any insights would be really appreciated C
__________________
_______________________________ Cendrinne |
#2
|
||||
|
||||
Are you asking about the code, ignoring the disabled lines or just the ones that are currently set to be active?
The active code lines will only work on the FIRST shape in the document. If you had a shape selected which isn't the first shape then it will be ignored. Is that what you wanted to happen? Let's look at this example if you re-enabled the loop. Say you have one shape in the document and it is a group of three shapes. Your loop starts and it only has one shape to work on. As it looks at the first (grouped) shape, it decides to ungroup the shape (which now becomes three shapes). Then the loop ends because when it started it was told to only work on one shape. So the questions are: Do you want the macro to work on all shapes in the document, on one selected shape only, or on every selected shape? If a shape is ungrouped, do you want its constituent parts to be set to textwrap square? If a grouped shape is ungrouped and one of the new parts is also a group, do you also want that ungrouped (until there are no more grouped elements)?
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
||||||
|
||||||
Actually, I wish to have a macro only on the selected group
I'm so sorry If I wastn't clearer, I'm aiming to do better.
Quote:
I'm wishing the code is on the selected Group of textbox Quote:
What I do, is select the outside frame of the group, and I've noticed if there are Group ''Lines'' further in the document, that is where it goes and totally ignored the selected outside group. HOWEVER, if I handle all the other Groups furter in the document, then the intended selected group, my code did the exactly what was intended [Square Warp & Ungroup] Quote:
OH I didn't think of that. Smart thinking! Quote:
I hope the macro would, I'll use your example of 3 textbox groupe as one: select the three textbox as one group, wrap square, then ungroup. Quote:
Yes I would Quote:
I'm not certain, what you are saying here, but how I see it, at times it's true in an example, a group of 6 textbox, built as one group, there might be two mini group, where ==> 1 group of 4 textbox, then created anoter group for the 2, then merged them all into 1 group at the end. Is that an example of what you are saying here? If so, let me explain the reason I've created this macro, maybe this would explain.....My intention of this macro is to : Either to use if for... 1- Just to use the selected group and wrap square, [Square cause I can move the group if needed, when inline, you cannot], this is a step prior to the next (==>End result, is to extract each content within a group and keep the text format, align to the left (but that is another macro); 2- OR if I need to undo a group of 6 textbox (using my previous example), but the group of 4, one of them should have been with the other mini group of 2 textbox. I hope my explanation if better. Thanks for the prompt reply C
__________________
_______________________________ Cendrinne |
#4
|
||||
|
||||
Try this version. I'm not sure how it will go with subgroups but it appears that you can the set wrapping for multiple selected graphics in a single line and when shapes are ungrouped they inherit the parents wrapping setting.
Code:
Sub Graph_CONVERT_TxtBox_to_WrapSquare_and_Ungroup() Dim aShp As Shape Selection.Range.ShapeRange.WrapFormat.Type = wdWrapSquare For Each aShp In Selection.Range.ShapeRange If aShp.Type = msoGroup Then aShp.Ungroup Next aShp End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
||||
|
||||
YES you did it!!!! Thank you so much
Your script did it without any problems, that I did encounter with mine.
I can't wait to be close to an expert Well I did progress in 7 years with Word I am truly grateful for your help and promptness. Until next time my friend, Andrew c
__________________
_______________________________ Cendrinne |
Tags |
help please, shapes, wrapping around image |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA Script that can convert XML Files to Word Doc. | Rolo18 | Word VBA | 11 | 03-31-2020 02:16 PM |
The "group or ungroup text range" control in the developer tab breaks my document up into many pages | damiansiniakowicz | Word | 8 | 05-10-2018 12:30 PM |
Setting a Group as Inline | mohsen.amiri | Word | 2 | 11-10-2017 03:16 AM |
Canvas + textbox + group = weird ghost bug? | somads | Word | 0 | 11-25-2015 01:37 AM |
Group records - multiple IF stmts - Text After Group | baum12 | Mail Merge | 1 | 05-25-2015 12:57 AM |