Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-20-2014, 12:32 AM
s_manoj s_manoj is offline Copy format, size, location Windows 8 Copy format, size, location Office 2010 32bit
Novice
Copy format, size, location
 
Join Date: Sep 2013
Posts: 3
s_manoj is on a distinguished road
Default Copy format, size, location

I need to copy size, position, formatting of one object and to apply to other objects on different slides through vba.

Thanks for your help.



Regards,

Manoj
Reply With Quote
  #2  
Old 05-20-2014, 04:54 AM
JohnWilson JohnWilson is offline Copy format, size, location Windows 7 64bit Copy format, size, location 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

Try:

Dim sngL As Single
Dim sngT As Single
Dim sngH As Single
Dim sngW As Single

Sub Pick_Up_Format()
'picks up format of selected shape
Dim oshp As Shape
On Error Resume Next
Err.Clear
Set oshp = ActiveWindow.Selection.ShapeRange(1)
If Err <> 0 Then
MsgBox "Select a shape!"
Else
sngL = oshp.Left
sngT = oshp.Top
sngW = oshp.Width
sngH = oshp.Height
oshp.PickUp
End If
End Sub

Sub Apply_Format()
' Apply to all selected shapes
Dim oshp As Shape
On Error Resume Next
Err.Clear
If sngH = 0 And sngW = 0 Then
MsgBox "Pick up format first."
Exit Sub
End If
For Each oshp In ActiveWindow.Selection.ShapeRange
If Err <> 0 Then
MsgBox "Select a shape!"
Else
oshp.Apply
oshp.Left = sngL
oshp.Top = sngT
oshp.Width = sngW
oshp.Height = sngH
End If
Next oshp
End Sub
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #3  
Old 05-20-2014, 09:53 PM
s_manoj s_manoj is offline Copy format, size, location Windows 8 Copy format, size, location Office 2010 32bit
Novice
Copy format, size, location
 
Join Date: Sep 2013
Posts: 3
s_manoj is on a distinguished road
Default

Hi,

Thanks.

If I select one object and chose Pick up format from macro and then I go the desired slide, where I select other object and choose Apply format. It shows msg as "choose pick up format" and tried 2-3 times but not get successes.

Regards,

Manoj
Reply With Quote
  #4  
Old 05-20-2014, 10:44 PM
JohnWilson JohnWilson is offline Copy format, size, location Windows 7 64bit Copy format, size, location 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

Did you copy and paste all of the code (including the four Dims)??

Download a sample here and see if it works
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #5  
Old 05-20-2014, 10:56 PM
s_manoj s_manoj is offline Copy format, size, location Windows 8 Copy format, size, location Office 2010 32bit
Novice
Copy format, size, location
 
Join Date: Sep 2013
Posts: 3
s_manoj is on a distinguished road
Default

Thanks for your reply. I had many macros, when I pasted including the four dims, the dims came below the last macro and others started as new macro.

I think, now it is working. Thanks for your help.
Reply With Quote
  #6  
Old 05-21-2014, 07:06 AM
JohnWilson JohnWilson is offline Copy format, size, location Windows 7 64bit Copy format, size, location 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

Yep declarations need to be at the top!
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy table to another location in the same document Sektor Word VBA 2 03-31-2014 09:28 PM
Copy format, size, location VBA to copy bookmark to a new location kent Word VBA 5 06-14-2012 02:18 PM
Copy format, size, location Copy & Paste Shapes & Motion Paths from 1 Slide Size to Another buckaroobanzai PowerPoint 1 06-08-2012 05:32 AM
Format template to allow user typing to jump to a new location dan28029 Word 2 02-13-2012 06:35 AM
Window Location & Size Ringmaster Outlook 0 09-14-2010 02:41 AM

Other Forums: Access Forums

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