Excel 在PPT中调整想象的大小不会';我不能在一台电脑上工作

Excel 在PPT中调整想象的大小不会';我不能在一台电脑上工作,excel,vba,powerpoint,Excel,Vba,Powerpoint,我试图创建一个宏,将Excel中的一个范围粘贴到PPT中,然后调整图片大小,但代码似乎跳过了调整大小的部分。我在另一台电脑上尝试了完全相同的代码,效果很好 Sub ExporttoPPT() Dim ppt_app As New PowerPoint.Application Dim pre As PowerPoint.Presentation Dim slde As PowerPoint.slide Dim shp As PowerPoint.shape Dim wb As Workbook

我试图创建一个宏,将Excel中的一个范围粘贴到PPT中,然后调整图片大小,但代码似乎跳过了调整大小的部分。我在另一台电脑上尝试了完全相同的代码,效果很好

Sub ExporttoPPT()

Dim ppt_app As New PowerPoint.Application
Dim pre As PowerPoint.Presentation
Dim slde As PowerPoint.slide
Dim shp As PowerPoint.shape
Dim wb As Workbook

Dim vSheet$
Dim vRange$
Dim vwidth As Double
Dim vheight As Double
Dim vtop As Double
Dim vleft As Double
Dim vsld As Long
Dim exprng As Range
Dim xlfile$
Dim pptfile$

Dim adminsh As Worksheet
Dim configrng As Range

Application.DisplayAlerts = False

Set adminsh = ThisWorkbook.Sheets("ExceltoPPT")
Set configrng = adminsh.Range("rng_sheets")

xlfile = adminsh.[excelpth]
pptfile = adminsh.[pptpth]

Set wb = Workbooks.Open([xlfile])
Set pre = ppt_app.Presentations.Open([pptfile])



Set adminsh = ThisWorkbook.Sheets("ExceltoPPT")
Set configrng = adminsh.Range("rng_sheets")



wb.Activate
For Each rng In configrng

'set variables

With adminsh
vSheet$ = .Cells(rng.Row, 3).Value
vRange$ = .Cells(rng.Row, 4).Value
vwidth = .Cells(rng.Row, 5).Value
vheight = .Cells(rng.Row, 6).Value
vtop = .Cells(rng.Row, 7).Value
vleft = .Cells(rng.Row, 8).Value
vsld = .Cells(rng.Row, 9).Value
End With

'export PPT


wb.Activate
Sheets(vSheet$).Activate
Set exprng = Sheets(vSheet$).Range(vRange$)
exprng.Copy

Set slde = pre.Slides(vsld)
slde.Shapes.PasteSpecial 2
Set shp = slde.Shapes(1)

With shp
.Top = vtop
.Left = vleft
.Width = vwidth
.Height = vheight
End With


Set shp = Nothing
Set slde = Nothing


Application.CutCopyMode = False
Set exprng = Nothing

'pre.Save
'pre.Close
Next rng
wb.Close False
Application.DisplayAlerts = True
End Sub
粘贴到PPT中效果很好,但调整大小似乎根本没有运行。我注意到的是

Dim slde As PowerPoint.slide
Dim shp As PowerPoint.shape 
有一个小写字母s,在它工作的PC上是大写字母s(它将其更正为小写字母s,即使它用大写字母表示形状)。我是VBA新手,所以它可能很简单,我不知道