OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy |
Determine The Direction Of A Line Shape |
|
This question was posed in a Microsoft newsgroup. The user wanted to determine the direction of inclination of the lines in his slides. Given below is a sample code put together to illustrate the line directions for you. I have not included code to detect perfectly vertical lines or perfectly horizontal lines. This is left for you as exercise. ' -------------------------------------------------------------------------------- ' Copyright ©1999-2018, Shyam Pillai, All Rights Reserved. ' -------------------------------------------------------------------------------- ' You are free to use this code within your own applications, add-ins, ' documents etc but you are expressly forbidden from selling or ' otherwise distributing this source code without prior consent. ' This includes both posting free demo projects made from this ' code as well as reproducing the code in text or html format. ' -------------------------------------------------------------------------------- 'The directions indicate the direction of creation of these lines. 'This code iterates thru all shapes on the first slide, 'locates the line shapes and prints out the directions Dim x As Slide Set x = ActivePresentation.Slides(1) 'Iterate thru all shapes on the slide For i = 1 To x.Shapes.Count With x.Shapes(i) ' Determine whether the current shape is a line If .Type = msoLine Then 'Check the VerticalFlip and HorizontalFlip properties of a line object 'to ascertain its direction. You need to extend this further to take 'care of Perfectly Vertical & Horizontal lines If .VerticalFlip = msoTrue Then If .HorizontalFlip = msoTrue Then Debug.Print "Line direction: North-West" Else Debug.Print "Line direction: North-East" End If Else If .HorizontalFlip = msoTrue Then Debug.Print "Line direction: South-West" Else Debug.Print "Line direction: South-East" End If End If End If End With Next i End Sub
|
|
MS forms do not support modeless display (97) and hence we make use of the Activate event of the UserForm to simulate a splash screen. Sleep API is used as a timer to resume code execution after a preset interval. Insert a UserForm into the VBA project. Double click on the UserForm and paste the code given below. '
-------------------------------------------------------------------------------- Private Declare Sub Sleep Lib
"kernel32" (ByVal dwMilliseconds As Long)
|
Copyright 1999-2018 (c) Shyam Pillai. All rights reserved.