VBA绝对路径改成相对路径 s

VBA绝对路径改成相对路径

set Shape = Slide.Shapes
set Picture9 = Shape.AddPicture("C:\Users\kaihzhan\Documents\PPT\day4\a.png",0,1,10,120,700,400)
这两句话怎么改成相对路径?
文件在同一文件夹里,试过去掉盘符,但是不能用
sub newppt
Set fso = CreateObject("Scripting.FileSystemObject")
Set objPPT = CreateObject("PowerPoint.Application")
Set objPresentation = objPPT.Presentations.Add
PageWidth = objPresentation.PageSetup.SlideWidth
PageHeight = objPresentation.PageSetup.SlideHeight
CustomPageWidth = objPresentation.PageSetup.SlideWidth
CustomPageHeight = objPresentation.PageSetup.SlideHeight

If objPresentation.HasTitleMaster Then
no = 1
set slides = objPresentation.Slides
set slide = slides.Add(no,1)
End If

set Slides = objPresentation.Slides
no = Slides.Count
no = no +1
set Slide = Slides.Item(1)

set Shape = Slide.Shapes
set Picture9 = Shape.AddPicture("C:\Users\kaihzhan\Documents\PPT\day4\a.png",0,1,10,120,700,400)
Picture9.PictureFormat.TransparencyColor = RGB(255, 255, 255)

Shape.AddPicture("C:\Users\kaihzhan\Documents\PPT\day4\a.png",0,1,10,120,700,400)

改成:
Shape.AddPicture(thisworkbook.Path & "\a.png",0,1,10,120,700,400)

我靠,我以为在Excel里面,
PPT改成
Shape.AddPicture(application.ActivePresentation.Path & "\a.png",0,1,10,120,700,400)

改成:
Shape.AddPicture(objPPT.ActivePresentation.Path & "\a.png",0,1,10,120,700,400)
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网