#1
|
|||
|
|||
Formatting picture
I use this code to format a picture - just a frame around it
Sub FormatPicture() ' ' FormatPicture Makro ' With Selection If .InlineShapes.Count <> 1 Then Exit Sub With .InlineShapes(1) With .Borders .Enable = True .OutsideLineWidth = wdLineWidth300pt <<<<<<<<<<<<<<<< crashes here when stepping through ??? .OutsideLineStyle = wdLineStyleSingle .OutsideColorIndex = wdBlack End With End With End With End Sub but it ONLY works if the picture is "in line with text" ! How can I change it to work on "flowting pictures too ? EDIT: Too I noticed that the machines freezes/crashes at the marked line when stepping through the code - why Last edited by ksor; 11-20-2020 at 09:02 AM. |
#2
|
|||
|
|||
Because floating objects are not inlineshapes.
Code:
Sub AddBorderToShape() Dim oShp As Shape On Error Resume Next Set oShp = Selection.ShapeRange(1) MsgBox Err.Number If Err.Number <> 0 Then Exit Sub With oShp .Line.ForeColor.RGB = RGB(0, 0, 0) .Line.Weight = 4 .Line.DashStyle = msoLineSolid End With End Sub |
#3
|
|||
|
|||
I don't know it your answer "Because floating objects are not inlineshapes." should
imply that your code would work - it doesn't - it gives Err.Number = 5 And still the machine freezes when stepping through the code And my Q was: "How can I change it to work on "flowting pictures too ?" |
#4
|
|||
|
|||
If you get an error number 5 it is because you don't have a floating shape selected.
Sometimes working with inline shapes and shape objects, that happens. |
#5
|
|||
|
|||
See video for example
|
#6
|
|||
|
|||
You're just repeating a not working solution with the comment "it happens sometimes !"
Here it happens every time I try to put a solid frame on my inline or flouting pictures. |
#7
|
|||
|
|||
Instead of grumbling about what I've posted why don't you try to better explain your problem. If you have a picture in a document that is in front of text, behind text, tight, square, etc. Then it is a "Shape" object (not an Inlineshape object). If you select the shape then the msgbox in the code I posted will return 0 instead of 5 and work as the video I posted proves.
As for the "freeze" okay it happens all the time when you have a shape or inlineshaped selected. Is that better?? |
#8
|
|||
|
|||
Step through this version of your original code. It won't hang because the inlineshape is no longer selected:
Code:
Sub Whine1() Dim oILS As InlineShape With Selection If .InlineShapes.Count <> 1 Then Exit Sub Set oILS = .InlineShapes(1) .Collapse wdCollapseEnd End With With oILS.Borders .Enable = True .OutsideLineWidth = wdLineWidth300pt .OutsideLineStyle = wdLineStyleSingle .OutsideColorIndex = wdBlack End With End Sub and this, it will format all the inlineshapes and shapes in the main text storyrange of the document. Code:
Sub WhineII() Dim oILS As InlineShape Dim oShp As Shape For Each oILS In ActiveDocument.InlineShapes With oILS.Borders .Enable = True .OutsideLineWidth = wdLineWidth300pt .OutsideLineStyle = wdLineStyleSingle .OutsideColorIndex = wdBlack End With Next oILS For Each oShp In ActiveDocument.Shapes With oShp .Line.ForeColor.RGB = RGB(0, 0, 0) .Line.Weight = 4 .Line.DashStyle = msoLineSolid End With Next End Sub |
#9
|
|||
|
|||
Grumbling
You should just read my original Q: "How can I change it to work on "flowting pictures too ?" and now you did ... and TOO made an exelent solution - THX ! |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inserting and formatting a picture | BLUEPUPIL | Word VBA | 2 | 04-28-2019 03:14 PM |
Picture formatting. | voyagerone | Drawing and Graphics | 3 | 05-31-2016 09:55 PM |
Picture Formatting Problem | thowes2 | Word | 1 | 04-24-2013 05:24 PM |
Picture Formatting Issues | mayj | Word | 1 | 04-02-2013 03:09 AM |
insert object or picture, strange formatting layout | qwertyjjj | Word | 5 | 01-10-2013 09:49 AM |