Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 09-02-2014, 05:55 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

Thank you very much for your time and expertise! It really means a lot.
I haven't had a chance to sit down and go through your posts in detail as I'm up to my eyes in work. I hope to get some time later this evening to go through it.
I will let you know how I get on.
Thanks again!
Reply With Quote
  #17  
Old 09-04-2014, 10:33 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

excelledsoftware, thank you very much for your time and expertise.
I have ran the final VBA code you posted and it works like a dream!
I have also been going down through the code and re-writing it into VBA to familiarize myself with it and gain an understanding of writing the code.
However, I have tried to run the first macro: GetTheLineColors but with no end result. I must be missing a step in the process; I definitely have the code correct, definitely ran the macro and I have enabled the macro security settings. I don't see any result to 'paste into Excell'.
Any further help you can offer is greatly appreciated.
Reply With Quote
  #18  
Old 09-04-2014, 10:52 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

Glad it worked out. Anytime you see the phrase debug.print in a block of a code it means that it is writing it to the immediate window. To see this window go to view in your visual basic editor and click the immediate window button. When you run the code you will see the results in this new window.
Reply With Quote
  #19  
Old 09-04-2014, 11:15 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

Well done Mr Excelled!

Where are you based?
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #20  
Old 09-04-2014, 12:15 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
Well done Mr Excelled!

Where are you based?
Oh my! that means so much coming from you. I am based in the US.
Reply With Quote
  #21  
Old 09-04-2014, 10:58 PM
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

Steve Rindsberg and I are running the Help Centre at the Presentation Summit in San Diego this October. If you're a PowerPoint Pro this is the very best conference!
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #22  
Old 09-04-2014, 11:39 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

Wow! I will have to keep it in mind. I wouldn't call my self a pro but I do like to use PPT and VBA.
Reply With Quote
  #23  
Old 09-08-2014, 06:48 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

excelledsoftware, I hope you don't mind me asking a bunch of questions but learning how to use VBA coding will often save me quite a bit of time.
I have been adapting your sub routine to change certain lines to different colors individually with no problem. However, in learning to use VBA properly I am trying to write code that will do this all at once and have ran into a bit of bother.
I have attached the PowerPoint file which I have been practicing on.

This is the code I've been trying to use to change multiple line colors and also the line weight of the black lines (this changes the text boxes' outline too for some reason). Any critique you can offer would be great.

Code:
Sub ChangeMultipleLineColors()

  Dim sld As Slide, shp As Shape, PurpleColor(1) As Long, WhiteColor(1) As Long, BlackColor(1) As Long, BlueColor(1) As Long, Arr As Byte
  Dim CheckColor As Long
  
    'Set GrayColors
    PurpleColor(1) = 16711807
    WhiteColor(1) = 16777215
    BlackColor(1) = 0
    BlueColor(1) = 12611584
    
    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
           
              If PurpleColor(1) = CheckColor Then
                shp.Line.ForeColor.RGB = BlueColor(1) 'Purple to Blue
                shp.Line.Weight = 1.5
                 If WhiteColor(1) = CheckColor Then
                   shp.Line.ForeColor.RGB = BlackColor(1) 'White to Black
                   shp.Line.Weight = 3 'Change Line Weight
                
                 End If
              End If
            
          End If
        Next shp
      Next sld
     
  MsgBox "All Done Richard! Have a good day."

End Sub

Also, I have been trying to write a code which will just select all of the blue lines so I can animate these but for some reason it keeps selecting one black, dashed line.

Code:
Sub SelectBlueLines()

  Dim sld As Slide, shp As Shape, GrayColor(1 To 2) As Long, Arr As Byte
  Dim CheckColor As Long
  
    'Set GrayColors
    GrayColor(1) = 12611584
  
  'White 16777215
  'Blue 12611584
  'Black 0
  
    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
              If GrayColor(1) = CheckColor Then
                shp.Select
               
           
                
              End If
          End If
        Next shp
    Next sld
       

  MsgBox "All Done Richard! Have a good day."

End Sub
Finally, do you know what the line of code to change a line from solid to 'Dash Type: Square Dot'?

Thanks again for your help!
Reply With Quote
  #24  
Old 09-08-2014, 06:51 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

The PPT file attached here.
Attached Files
File Type: pptx Presentation2.pptx (160.5 KB, 8 views)
Reply With Quote
  #25  
Old 09-08-2014, 09:33 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

Some comments

In the first code your End If are not correctly placed. After checking for Purple the code will jump past the check for White which will never take place.

Try this instead

Code:
ub ChangeMultipleLineColors()

Dim sld As Slide, shp As Shape, PurpleColor As Long, WhiteColor As Long, BlackColor As Long, BlueColor As Long, Arr As Byte
Dim CheckColor As Long

'Set Colors
'These are not arrays so forget the (1)
PurpleColor = 16711807
WhiteColor = 16777215
BlackColor = 0
BlueColor = 12611584

For Each sld In ActivePresentation.Slides
    'sld.Select 'not necessary and not a good idea
    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 as above
            CheckColor = shp.Line.ForeColor.RGB
            Select Case CheckColor
                Case Is = PurpleColor
                    shp.Line.ForeColor.RGB = BlueColor    'Purple to Blue
                    shp.Line.Weight = 1.5
                Case Is = WhiteColor
                    shp.Line.ForeColor.RGB = BlackColor    'White to Black
                    shp.Line.Weight = 3    'Change Line Weight
            End Select
        End If
    Next shp
Next sld

MsgBox "All Done Richard! Have a good day."

End Sub
To select all the shapes of one color you need to understant that .Select will usually only select the last item.

Code:
Sub SelectBlueLines()

Dim sld As Slide, shp As Shape
' this selcts the purple lines in the sample
' you cannot select shapes on multiple slides
' so choose just one
Set sld = ActivePresentation.Slides(1)
' unselect anything already selected
ActiveWindow.Selection.Unselect
Debug.Print sld.SlideIndex    'again not necessary but useful if errors
For Each shp In sld.Shapes
    If shp.Type = msoLine Then
        ' When you select the default behaviour is to deselect anything already selected
        ' You will end up the last selection only UNLESS
        ' you specify "Do not replace"
        If shp.Line.ForeColor = RGB(127, 0, 255) Then shp.Select Replace:=msoFalse
    End If
Next shp
MsgBox "All Done Richard! Have a good day."

End Sub
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials

Last edited by JohnWilson; 09-09-2014 at 12:18 AM.
Reply With Quote
  #26  
Old 09-08-2014, 10:46 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

Okay, I think I'm getting a handle on most of it now.
Can you recommend the best source of information about VBA coding to help me become more competent with it?
Thank you again.
Reply With Quote
  #27  
Old 09-08-2014, 06:05 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

Your off to a great start. I first started learning VBA by asking John Wilson for some code snippets. He always delivers and writes very clean code. I studied it and not everything made sense at first. I started to learn programming concepts and then it started to click immediately. I have a website that teaches beginning VBA and programming but I dont like to be a self advertiser so you would need to PM me if you wanted that info. Lots of youtube videos out there that teach VBA but the one thing I can tell you. No matter where you go to try and learn VBA if the programming itself dosnt make sense it will be a doable but painful process. I speak from experience.
Reply With Quote
  #28  
Old 09-09-2014, 12:35 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

A few people who program for major companies also publish code snippets. Studying these is a great way to learn.

Before you do this I would spend a day or so just learning some good habits it will pay off later.

e.g.
Why you should always declare variables (even though vba works without)
Why you should use the correct type of variable (again even though vba is very forgiving about this)
Why a naming convention for variables is a great idea.

Some good places to study code

Our site
Steve Rindsberg's PPTFAQ
Shyam Pillai (usually more complex stuff)

There are more but there's lots to study there
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
Reply

Tags
lines, multiple, select

Thread Tools
Display Modes


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 10:29 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