Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba .PPT宏已启用显示路径_Vba_File_Path_Powerpoint_Show - Fatal编程技术网

Vba .PPT宏已启用显示路径

Vba .PPT宏已启用显示路径,vba,file,path,powerpoint,show,Vba,File,Path,Powerpoint,Show,我试图在PowerPoint中将演示文稿保存为启用宏的演示文稿,但在保存时遇到了问题。当我保存为启用宏的演示文稿时,我使用的这段代码非常有效,但不能保存为启用宏的演示文稿。: Dim oPPTApp As PowerPoint.Application Dim oPPRFile As PowerPoint.Presentation Dim oPPTShape As PowerPoint.PlaceholderFormat Dim oPPTSlide As PowerPoint.Slide Set

我试图在PowerPoint中将演示文稿保存为启用宏的演示文稿,但在保存时遇到了问题。当我保存为启用宏的演示文稿时,我使用的这段代码非常有效,但不能保存为启用宏的演示文稿。:

Dim oPPTApp As PowerPoint.Application
Dim oPPRFile As PowerPoint.Presentation
Dim oPPTShape As PowerPoint.PlaceholderFormat
Dim oPPTSlide As PowerPoint.Slide

Set oPPTApp = CreateObject("PowerPoint.Application")
oPPTApp.Visible = msoTrue

'opening an existing presentation

Dim spath2 As String
Dim strpath2 As String
spath2 = ActivePresentation.Path <--
strpath2 = spath2 + "\Resources\AIT Diplomas\AIT Diplomas.pptx"
Dim opptap作为PowerPoint.Application
将OpperFile设置为PowerPoint。演示文稿
将oPPTShape设置为PowerPoint.Placeholder格式
将oPPTSlide变暗为PowerPoint。幻灯片
Set opptap=CreateObject(“PowerPoint.Application”)
opptap.Visible=msoTrue
'打开现有演示文稿
以字符串形式显示
作为字符串的Dim strpath2

spath2=ActivePresentation.Path既然您还没有回答我关于代码从何处运行的问题,我将假设它来自PPT,并且不涉及其他应用程序。在这种情况下,无论是从PPTM还是PPSM,这都可以正常工作:

Sub MittedForYourApproval()

' if the code is running within PPT, you don't need to do it this way:
' PPT has a reference to itself.
'Dim oPPTApp As PowerPoint.Application
'Dim oPPRFile As PowerPoint.Presentation
'Dim oPPTShape As PowerPoint.PlaceholderFormat
'Dim oPPTSlide As PowerPoint.Slide

Dim oPPRFile As Presentation
' I don't know where you're going with this
' but PlaceholderFormat <> a shape
Dim oPPTShape As PlaceholderFormat
Dim oPPTSlide As Slide

'Set oPPTApp = CreateObject("PowerPoint.Application")
'oPPTApp.Visible = msoTrue

'opening an existing presentation

Dim spath2 As String
Dim strpath2 As String
spath2 = ActivePresentation.Path '<--
'strpath2 = spath2 + "\Resources\AIT Diplomas\AIT Diplomas.pptx"
MsgBox spath2

End Sub
submittedforourapproval()
'如果代码在PPT中运行,则不需要这样做:
“PPT有一个自我参照。
'将OPPTAP设置为PowerPoint.Application
'将OpperFile设置为PowerPoint.Presentation
'将oPPTShape设置为PowerPoint.Placeholder格式
'将幻灯片变暗为PowerPoint。幻灯片
作为演示文稿的文件
“我不知道你拿着这个要去哪里
'但要设置形状的格式
Dim oPPTShape作为占位符格式
像滑梯一样变暗
'Set opptap=CreateObject(“PowerPoint.Application”)
'opptap.Visible=msoTrue
'打开现有演示文稿
以字符串形式显示
作为字符串的Dim strpath2

spath2=ActivePresentation.Path的问题/建议:此代码应该在现有的正在运行的幻灯片演示文稿中运行,还是在另一个应用程序中运行?使用&而不是+进行字符串连接,否则VB最终会咬到你。是否尝试将启用宏的演示文稿保存为扩展名为.PPTX的文件?那也不行。PPTM或PPSMHi Steve,感谢您的回复。感谢您提供有关&而不是+的提示。我没有试图将文件保存在代码中,我只是将其作为演示文稿进行处理,然后将其保存为启用宏的显示,出现上述错误(因为显示路径进入“C:…Microsoft Office\Excel”,而不是保存的启用宏的显示的起始位置(我希望覆盖该位置)。在出现错误之前发布更多的代码可能是一个好主意。不幸的是,这就是代码。它在演示文稿打开时工作,但在没有演示文稿的情况下不能进行宏显示。如果您有powerpoint,请打开一个新演示文稿,然后使用activepresentation.path在msgbox中显示路径。这样可以正常工作。然后另存为一个启用宏功能的节目,它将不起作用。我正在尝试解决这个问题。请参阅最新发布的答案。史蒂夫,这非常有效。为了让我更好地理解,OpperFile、oPPTShape和oPPTSlide只是“唤醒”一个演示文稿?我只是想知道这是如何解决问题的:)非常感谢!另外,它说我没有足够的信誉点来标记这是正确的:/oPPRFile、oPPTShape等是对象变量,分别包含对演示文稿、占位符格式和幻灯片的引用。只要您在PPT本身中使用它们,就不需要从PPT应用程序的引用开始,因为它是隐式的。老实说,我说不出为什么它以前不起作用。奇怪,不是吗?