Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-01-2023, 07:16 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup Windows 10 Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup Office 2019
Competent Performer
Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Question 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
What am I doing wrong? Been trying to find the logic, and I can't figure it out.

Any insights would be really appreciated

C
Reply With Quote
  #2  
Old 06-02-2023, 12:42 AM
Guessed's Avatar
Guessed Guessed is offline Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup Windows 10 Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,975
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

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
Reply With Quote
  #3  
Old 06-02-2023, 09:02 AM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup Windows 10 Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup Office 2019
Competent Performer
Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default 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:
Originally Posted by Guessed View Post
Are you asking about the code, ignoring the disabled lines or just the ones that are currently set to be active?
I'm wishing the code is on the selected Group of textbox
Quote:
Originally Posted by Guessed View Post
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?
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:
Originally Posted by Guessed View Post
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.
OH I didn't think of that. Smart thinking!
Quote:
Originally Posted by Guessed View Post
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?
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:
Originally Posted by Guessed View Post
If a shape is ungrouped, do you want its constituent parts to be set to textwrap square?
Yes I would
Quote:
Originally Posted by Guessed View Post
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)?
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
Reply With Quote
  #4  
Old 06-02-2023, 09:13 PM
Guessed's Avatar
Guessed Guessed is offline Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup Windows 10 Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,975
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

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
Reply With Quote
  #5  
Old 06-03-2023, 01:40 AM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup Windows 10 Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup Office 2019
Competent Performer
Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default 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
Reply With Quote
Reply

Tags
help please, shapes, wrapping around image



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup VBA Script that can convert XML Files to Word Doc. Rolo18 Word VBA 11 03-31-2020 02:16 PM
Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup 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
Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:30 AM.


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