Left Position does not work

ganeshpoojary05

Board Regular
Joined
Apr 26, 2011
Messages
105
Dear All,

I need a help in positioning my PPT table to extremely left. The below code works fine, however I'm not able to position the range to extremely left in my slide. Request you to provide me the solution. Thanks in advance for your help.

Below is the code for your reference:


Option Explicit

Private PPT As powerpoint.Application
Private PPT_pres As powerpoint.presentation

Private Sub OpenPowerpoint()
Set PPT = New powerpoint.Application

PPT.Visible = True
Set PPT_pres = PPT.Presentations.Open(Filename:="C:\PPT Automation\PMS Presentation.pptx")
'PPT_pres.Slides(5).Select
Call CopyToPowerPoint
End Sub

Private Sub CopyToPowerPoint()
If PPT Is Nothing Then Exit Sub
If PPT_pres Is Nothing Then Exit Sub

Dim rng As Range
Dim mySlide As Object
Dim myShape As Object


Set mySlide = PPT_pres.Slides(5)

'Copy Range from Excel

Set rng = ThisWorkbook.Sheets("Slide 5").Range("B5:F12")

'Copy Excel Range
rng.Copy

'Paste to PowerPoint and position
PPT.WindowState = 2
mySlide.Shapes.PasteSpecial DataType:=8
Set myShape = mySlide.Shapes(mySlide.Shapes.Count)


'Set position:

myShape.Left = 5
myShape.Top = 0
myShape.Width = 350
myShape.Height = 150


'Clear The Clipboard
Application.CutCopyMode = False
Application.Wait (Now + TimeValue("00:00:01"))

End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
With the exception of changing the names of the pptx file and the sheet name so I can use my own test items, your code seems to work fine. Stepping through the code shows that the table is pasted first in the center of the slide and then it is moved to the top left and resized. What is yours doing that is not this? Or what different settings were you expecting?
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top