我嘗試打開,修改和保存演示文稿,但它總是被開闢爲只讀:VBA:PPT課件演示打開爲只讀
If measTypesDict.Exists(MeasType) = False Then
Dim targetPath As String
Dim newPres As PowerPoint.presentation
measTypesDict.Add MeasType, New Dictionary
Set newPres = PowerPoint.Application.Presentations.Add(msoFalse)
targetPath = rootDir & "\final\" & MeasType & ".ppt"
newPres.SaveAs targetPath
' newPres.Close that is what's been missing
targetPresentationsDict.Add MeasType, Presentations.Open(targetPath, ReadOnly:=msoFalse, WithWindow:=msoFalse)
End If
The ReadOnly parameter is used to open a presentation as Read-Only.
The following example opens a file named test.ppt as Read-Only.
Sub OpenPresentationReadOnly()
Presentations.Open "c:\test.ppt", msoTrue
End Sub
任何人都可以給我一個提示,爲什麼這是這種情況?我是目標文件夾的所有者,並根據文件夾設置完全控制。
該文件是否已保存爲「只讀」? –
我想我得到了解決方案。我使用'Presentations.Add(msoFalse)'添加了演示文稿,然後保存爲'newPres.SaveAs targetPath'。 **現在**我調用'newPres.Close'並重新打開該演示文稿。現在我有寫入權限 - 但我不太喜歡這個事實,我必須重新打開它。 – displayname
如果您正在執行保存,那麼爲什麼要重新打開它?它已經打開... –