Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-27-2014, 10:59 AM
RFoudy RFoudy is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2010 64bit
Novice
Quickly select lines of certain colour
 
Join Date: Aug 2014
Posts: 8
RFoudy is on a distinguished road
Default Quickly select lines of certain colour

Hi all,
I have a large number of slides with different colour lines and want to change the colour of all the grey lines to blue. The colours would have been applied individually separate to any themes. I was thinking about using macros but I don't know enough about them to carry out the operation.
I have researched this online but to no avail, any help you can offer me is greatly appreciated.

Kind Regards,


Richard
Reply With Quote
  #2  
Old 08-28-2014, 12:31 AM
excelledsoftware excelledsoftware is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

If you could post a sample presentation that has the gray lines and the desired blue line result I could write you a code that would take care of it for you in a couple of seconds.
Reply With Quote
  #3  
Old 08-28-2014, 03:53 AM
JohnWilson JohnWilson is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Are all the lines EXACTLY the same gray?
Do you mean lines as in connecters or lines as in shape borders?
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #4  
Old 08-28-2014, 06:58 AM
RFoudy RFoudy is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2010 64bit
Novice
Quickly select lines of certain colour
 
Join Date: Aug 2014
Posts: 8
RFoudy is on a distinguished road
Default

Hi, thanks for the responses. I have attached one of the slides to this post.
The lines would have been originally drawn in AutoCAD, saved as a metafile and then imported into PowerPoint with colour applied individually within PowerPoint.
I would love if you can show me how to write the code as I will no doubt have the same problem with other slides very soon.
Thank you.
Attached Files
File Type: pptx Toaster.pptx (422.9 KB, 11 views)
Reply With Quote
  #5  
Old 08-28-2014, 06:38 PM
excelledsoftware excelledsoftware is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

I would be happy to help you learn basically the program would be a loop that looks at every slide and every shape on it. If a shape meets the criteria (the line is a gray) then the code would turn it blue and move on to the next shape.

The gray appears to be a line forecolor of 10921638 while the blue is a forecolor of 16711680

Now a couple things

I basically already wrote the code that will do this however since you want to learn we need to go over it at your speed. You mentioned you dont know enough about macros so do you have any VBA experience or programming experience in general? its ok if you dont we just need to know where to start.

and to John Wilson the most amazing PPT programmer I have ever come in contact with. If I am treading on your territory please let me know and I can back off. I respect you so much.
Reply With Quote
  #6  
Old 08-29-2014, 04:12 AM
RFoudy RFoudy is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2010 64bit
Novice
Quickly select lines of certain colour
 
Join Date: Aug 2014
Posts: 8
RFoudy is on a distinguished road
Default

I have very limited experience with VBA. I use basic macros now and then but never have edited the code/text within VBA. I have messed around with .html code on a website before, nothing major, just editing font really.
Reply With Quote
  #7  
Old 08-29-2014, 07:00 AM
JohnWilson JohnWilson is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Go for Excelled I am pretty busy with a large US Law firm right now.
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #8  
Old 08-29-2014, 07:00 PM
excelledsoftware excelledsoftware is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Quote:
Originally Posted by JohnWilson View Post
Go for Excelled I am pretty busy with a large US Law firm right now.
Thanks John,

I will try to make you proud
Reply With Quote
  #9  
Old 08-29-2014, 07:49 PM
excelledsoftware excelledsoftware is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Ok RFoudy,

Now that I have an idea of your experience level I will be more than happy to get you started with VBA coding. Now the big thing to understand is that this will be a process a lot of it will not make sense at first but you are just getting your feet wet.

You mentioned that you have done some HTML editing. That's great it gives you the opportunity to see how changing code of any kind can produce a different result.

so let's start with your project here. It is important to understand the logic of what you want the computer to do. You want code to look at all all sildes for each slide you want the code to look at all shapes. Determine if they are gray and then color them blue. After that we want the code to continue to the next shape then the next slide and repeat.

Some keywords to think about here are: All, every, repeat etc. When these words are used in your plan you need what is called a loop. A loop will execute a block of code and then keep on going until you tell it when to stop.

The other words used are: if

If statements are used in nearly every programming language they tell the code to execute something IF it meets a condition.

With that we now know that the code for this will consist of a loop that looks at all slides, in that loop we have another loop that looks at every shape on the slide. Within that loop an If statement that checks if the line is gray.

OK sounds fun dosnt it? Lets start with setting up the code so Powerpoint knows what we want it to do.

We will not go over every detail here but rather an introduction to the objects we are about to use.

In the next post we will start with the code and I will explain it as I go.
Reply With Quote
  #10  
Old 08-30-2014, 02:17 PM
excelledsoftware excelledsoftware is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Sorry about the the late reply but I did notice that not all of the gray lines are the same kind of gray. That poses a huge problem with writing a basic code. The first thing to do is to write a procedure that will tell us all of the line color numbers.

Follow along with the simple code that does nothing more than give us the line color for each shape on slide 1. This is a great way to see a loop work.

Now everytime I go to explain something in the code I will use a ' This represents a comment in VBA. Comments are not code executed but rather a message to the programmer or anybody looking over the code.

Here we go.

Code:
Sub GetTheLineColors()
  'This is the very first thing you write for every procedure.  Sub
  'Just tells VBA that you are writing a sub routine.
  'The GetTheLineColors is just a name I came up with.  You can use
  'Whatever you want but it can contain most special characters
  'and no spaces.  The () will be written automatically for you as well
  'as an End Sub
  
  

  Dim shp As Shape
  'Here we use the Dim keyword that is used to DECLARE a variable.
  'I will not go over variables in detail here just know that a variable
  'Holds information so it can be used throughout the code.
  'You can use almost whatever name for a variable you want.
  'I used shp because it makes the most sense. and Shape is already taken
  'because it is used in PPT VBA already just like I could not make a variable called
  'ActivePresentation.

  For Each shp In ActivePresentation.Slides(1).Shapes
  'There are several loops available.  This one is called the for each
  'It basically says that FOR this instance do something
  'In this case it is going to go through each shape in the
  'Active presentation's Slides and shapes
  'Notice I put in Slides(1) This checks just the first slide.
  'When we write the second code you will see how we change that and why.
  
    Debug.Print shp.Name & ";" & shp.Line.ForeColor.RGB
    'Debug.print basically writes a string to the immediate window.
    'in this case I have the shape name a ; and then the linecolor which
    'is what we are after.  I am separating the 2 with a ; so I can copy
    'and paste the result into Excel and separate them into columns.
    
    
  Next shp
  
  'For any loop you need to tell it to keep going.  The For loop
  'Uses the next statement which says "now that you are done with that
  'code block move to the next shape and continue until EACH shape has been
  'visited.
  
  'Remember how I said End Sub would be written in.  Here it is
  'This tell VBA that the procedure is over
End Sub
Now that was quite a bit to go over but again you are just getting your feet wet here.

Once I ran that code I copy and pasted the result into Excel and then I manually changed all of the "Gray" lines to a consistent green color. Then I ran the the same script again and compared how many Gray variations there are.

Here are the results.
10921638
12287562

So there are 2 possibilities of Gray lines here. 2 is not that big of a deal since an
IF statement could easily check 2 conditions but since you will want to be able to
do this in the future you will be learning about arrays as well and we will need to put another loop into our next procedure but first you need to use the code above and try this yourself. It's important to understand how the loop works. What would be awesome is if you could use the loop to identify what line color of blue you are looking for. Post that and I will continue to write the code for the next part since it still needs something else.
Reply With Quote
  #11  
Old 08-30-2014, 02:19 PM
excelledsoftware excelledsoftware is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

By the way this is what that same code would like without all of the comments.
It does the very same thing
Code:
Sub GetTheLineColors()

  Dim shp As Shape

    For Each shp In ActivePresentation.Slides(1).Shapes
      Debug.Print shp.Name & ";" & shp.Line.ForeColor.RGB
    Next shp

End Sub
Reply With Quote
  #12  
Old 08-30-2014, 03:31 PM
excelledsoftware excelledsoftware is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

RFoudy,

I have the procedure written now and it works. However one thing that will make it more complex is if you have groups that need the line colors changed. It can certainly be done but I would need to debug it a little bit. Right now I have skipping over groups and it worked 100% for the sample you sent me. Let me know if this is not an issue and if it isnt I will post it with some explanations and you will be all set.


EDIT

I will post it now and if you want we can go over it
Code:
Sub ChangeLineColor()

  Dim sld As Slide, shp As Shape, GrayColor(1 To 2) As Long, Arr As Byte
  Dim CheckColor As Long
  
    'Set GrayColors
    GrayColor(1) = 10921638
    GrayColor(2) = 12287562
  

    For Each sld In ActivePresentation.Slides
      sld.Select 'not necessary but fun to watch
      Debug.Print sld.SlideIndex 'again not necessary but useful if errors
        For Each shp In sld.Shapes
          If shp.Type <> msoGroup Then
            shp.Select 'not necessary but fun to watch
            CheckColor = shp.Line.ForeColor.RGB
            For Arr = 1 To 2
              If GrayColor(Arr) = CheckColor Then
                shp.Line.ForeColor.RGB = 12287562 'Change to blue
              End If
            Next Arr     
          End If
        Next shp
      Next sld
  MsgBox "done"

End Sub
Let me know if that works. As with all code be sure to back up your work before running it because you cannot undo a macro.
Reply With Quote
  #13  
Old 08-31-2014, 06:03 AM
JohnWilson JohnWilson is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

I had to add a third gray to make it work for all lines

GrayColor(3) = 12566463
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #14  
Old 08-31-2014, 09:10 AM
excelledsoftware excelledsoftware is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Hi John,

Thanks for that catch I must have ran my GetTheLIneColors after I made a change to one of the gray lines and missed it.
Reply With Quote
  #15  
Old 08-31-2014, 09:45 AM
excelledsoftware excelledsoftware is offline Quickly select lines of certain colour Windows 7 64bit Quickly select lines of certain colour Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Here is the new code with John Wilson's find
Code:
Sub ChangeLineColor()

  Dim sld As Slide, shp As Shape, GrayColor(1 To 3) As Long, Arr As Byte
  Dim CheckColor As Long
  
    'Set GrayColors
    GrayColor(1) = 10921638
    GrayColor(2) = 12287562
    GrayColor(3) = 12566463
  

    For Each sld In ActivePresentation.Slides
      sld.Select 'not necessary but fun to watch
      Debug.Print sld.SlideIndex 'again not necessary but useful if errors
        For Each shp In sld.Shapes
          If shp.Type <> msoGroup Then
            shp.Select 'not necessary but fun to watch
            CheckColor = shp.Line.ForeColor.RGB
            For Arr = 1 To 3
              If GrayColor(Arr) = CheckColor Then
                shp.Line.ForeColor.RGB = 12287562 'Change to blue
              End If
            Next Arr     
          End If
        Next shp
      Next sld
  MsgBox "done"

End Sub
Reply With Quote
Reply

Tags
lines, multiple, select



Similar Threads
Thread Thread Starter Forum Replies Last Post
Quickly select lines of certain colour Way to find comments quickly ep2002 Word 2 12-18-2013 02:03 AM
Quickly add file path name to footer nimblewit Word 2 05-03-2013 05:17 AM
Quickly select lines of certain colour Is there a function to easily and quickly highlight? Verbum Word 3 02-05-2013 10:09 AM
Quickly select lines of certain colour How do I Insert Acrobat PDF pages into Word Canvases quickly? hemi_fan Word 1 04-12-2012 08:07 PM
finding contacts quickly Jackdeanperry Outlook 0 12-21-2009 11:28 AM

Other Forums: Access Forums

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