Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-18-2019, 11:29 AM
wolverineblaine wolverineblaine is offline Alter Thickness of All Circles in Document Windows 10 Alter Thickness of All Circles in Document Office 2019
Novice
Alter Thickness of All Circles in Document
 
Join Date: Mar 2019
Location: Michigan
Posts: 7
wolverineblaine is on a distinguished road
Default Alter Thickness of All Circles in Document

I have a document created by someone else with nearly 100 pages and probably 1000 circles. I need to write some vba code to change the thickness to 4.5 (it is currently 0.75).

I have never written any vba code before, but have used small sections obtained online in the past. Any help would be greatly appreciated.

I'm thinking the code would need to select the shape, set the thickness then move onto the next shape altering the same property in a loop.

Here is what i have so far...

Sub CircleThickness()
With ActiveDocument.Shapes(1)
.AutoShapeType = msoShapeOval


.Line.Weight = 4.5
End Sub
Attached Files
File Type: docm MathPuzzleSample.docm (55.5 KB, 6 views)
Reply With Quote
  #2  
Old 03-18-2019, 12:32 PM
gmaxey gmaxey is offline Alter Thickness of All Circles in Document Windows 10 Alter Thickness of All Circles in Document Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

If you all the shapes are in fact AutoShapes and AutoShapeType msoTypeOval then this should work:

Sub ResetShapeLineWT()
Dim oShp As Shape
For Each oShp In ActiveDocument.Shapes
If oShp.AutoShapeType = msoShapeOval Then
oShp.Line.Weight = 4.5
End If
Next
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 03-18-2019, 07:03 PM
wolverineblaine wolverineblaine is offline Alter Thickness of All Circles in Document Windows 10 Alter Thickness of All Circles in Document Office 2019
Novice
Alter Thickness of All Circles in Document
 
Join Date: Mar 2019
Location: Michigan
Posts: 7
wolverineblaine is on a distinguished road
Default

Thanks! - that worked for all the typical circles. There are circles that were unaffected by the code inside a rectangle with rounded corners and also appear to be on a drawing canvas.

When I look at the selection pane - those "ovals" are part of a numbered 'canvas' - do you have a way to modify the circles on the canvas as well?
Reply With Quote
  #4  
Old 03-18-2019, 07:50 PM
Guessed's Avatar
Guessed Guessed is offline Alter Thickness of All Circles in Document Windows 10 Alter Thickness of All Circles in Document 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

I haven't played with the drawing canvas before. This appears to work
Code:
Sub ResetShapeLineWT()
  Dim oShp As Shape, oCShp As CanvasShapes, i As Integer
  For Each oShp In ActiveDocument.Shapes
    If oShp.AutoShapeType = msoShapeOval Then
      oShp.Line.Weight = 4.5
    ElseIf oShp.CanvasItems.Count > 0 Then
      For i = 1 To oShp.CanvasItems.Count
        If oShp.CanvasItems(i).AutoShapeType = msoShapeOval Then
          oShp.CanvasItems(i).Line.Weight = 4.5
        End If
      Next i
    End If
  Next
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 03-19-2019, 05:33 AM
wolverineblaine wolverineblaine is offline Alter Thickness of All Circles in Document Windows 10 Alter Thickness of All Circles in Document Office 2019
Novice
Alter Thickness of All Circles in Document
 
Join Date: Mar 2019
Location: Michigan
Posts: 7
wolverineblaine is on a distinguished road
Default

I got an error - "This member can only be accessed for a group"

debug has an issue with "ElseIf oShp.CanvasItems.Count > 0 Then"

see attached screenshots.
Attached Images
File Type: jpg 2019 03 19 error 1.JPG (17.8 KB, 14 views)
File Type: jpg 2019 03 19 error 2.JPG (34.3 KB, 14 views)
Reply With Quote
  #6  
Old 03-19-2019, 01:04 PM
gmaxey gmaxey is offline Alter Thickness of All Circles in Document Windows 10 Alter Thickness of All Circles in Document Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Try this:

Code:
Sub ResetShapeLineWT2()
Dim oShp As Shape
Dim lngIndex As Long
  For Each oShp In ActiveDocument.Shapes
    Select Case oShp.Type
      Case 1
        If oShp.AutoShapeType = msoShapeOval Then
          oShp.Line.Weight = 4.5
        End If
      Case 20
        For lngIndex = 1 To oShp.CanvasItems.Count
          If oShp.CanvasItems(1).Type = 1 Then
            If oShp.CanvasItems(1).AutoShapeType = msoShapeOval Then
              oShp.CanvasItems(1).Line.Weight = 4.5
            End If
          End If
        Next
    End Select
  Next
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #7  
Old 03-19-2019, 02:20 PM
wolverineblaine wolverineblaine is offline Alter Thickness of All Circles in Document Windows 10 Alter Thickness of All Circles in Document Office 2019
Novice
Alter Thickness of All Circles in Document
 
Join Date: Mar 2019
Location: Michigan
Posts: 7
wolverineblaine is on a distinguished road
Default

No errors, it just didn't change the circles inside the drawing canvas. It did change the other circles, however.
Reply With Quote
  #8  
Old 03-19-2019, 03:07 PM
Guessed's Avatar
Guessed Guessed is offline Alter Thickness of All Circles in Document Windows 10 Alter Thickness of All Circles in Document 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

Which might be because your ovals inside canvas items are grouped. The grouping of objects can get complicated with groups inside groups.

You are going to need to provide a sample document containing items that the macro is not currently hitting. If your canvas items have different levels of grouping then you need to provide samples of each.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #9  
Old 03-20-2019, 09:28 AM
wolverineblaine wolverineblaine is offline Alter Thickness of All Circles in Document Windows 10 Alter Thickness of All Circles in Document Office 2019
Novice
Alter Thickness of All Circles in Document
 
Join Date: Mar 2019
Location: Michigan
Posts: 7
wolverineblaine is on a distinguished road
Default

Here the example document. I attached it to the original post, but here it is again.
Attached Files
File Type: docm Math Puzzle Sample.docm (57.8 KB, 7 views)
Reply With Quote
  #10  
Old 03-20-2019, 11:31 AM
wolverineblaine wolverineblaine is offline Alter Thickness of All Circles in Document Windows 10 Alter Thickness of All Circles in Document Office 2019
Novice
Alter Thickness of All Circles in Document
 
Join Date: Mar 2019
Location: Michigan
Posts: 7
wolverineblaine is on a distinguished road
Default

This one shows the circles on the left that are being correctly adjusted and the circles on the right that are un-effected by the code.
Attached Files
File Type: docm MathPuzzleSample.docm (59.0 KB, 7 views)
Reply With Quote
  #11  
Old 03-20-2019, 01:54 PM
gmaxey gmaxey is offline Alter Thickness of All Circles in Document Windows 10 Alter Thickness of All Circles in Document Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Try this:
Code:
Sub ResetShapeLineWT2()
Dim oShp As Shape
Dim lngIndex As Long
  For Each oShp In ActiveDocument.Shapes
    Select Case oShp.Type
      Case 1
        If oShp.AutoShapeType = msoShapeOval Then
          oShp.Line.Weight = 4.5
        End If
      Case 20
        For lngIndex = 1 To oShp.CanvasItems.Count
          If oShp.CanvasItems(lngIndex).Type = 1 Then
            If oShp.CanvasItems(lngIndex).AutoShapeType = msoShapeOval Then
              oShp.CanvasItems(lngIndex).Line.Weight = 4.5
            End If
          End If
        Next
    End Select
  Next oShp
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #12  
Old 03-20-2019, 08:02 PM
wolverineblaine wolverineblaine is offline Alter Thickness of All Circles in Document Windows 10 Alter Thickness of All Circles in Document Office 2019
Novice
Alter Thickness of All Circles in Document
 
Join Date: Mar 2019
Location: Michigan
Posts: 7
wolverineblaine is on a distinguished road
Default

It worked!!! thank you so much!! After running the code on the test document, I also ran it on the two actual documents containing 75 pages and 100 pages each and all the circles have been successfully changed. Thanks again.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you alter font/size within Task folders lsg267 Office 0 06-16-2017 07:45 AM
Alter Thickness of All Circles in Document divided circles ericvorlage Excel 1 01-26-2014 11:07 AM
Alter Thickness of All Circles in Document End or alter a loop? DJSOUND Word VBA 1 10-11-2013 08:11 PM
Alter Thickness of All Circles in Document Alter right click menu? markg2 Office 1 01-10-2011 08:10 AM
Circles Toruk-Mach-Toh Word 0 03-16-2010 05:33 AM

Other Forums: Access Forums

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