当按下幻灯片上的操作按钮时,我搜索了一种方法,以幻灯片模式将当前幻灯片保存为图片。这就是我最终想出来的:
`Sub SaveCurrentSlideAsJpg()`
Dim imagePath As String
Dim slideNum As Integer
imagePath = "C:\Users\XXXXX\Pictures\Slides\"
slideNum = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex
' first check if this already exists then delete it
If Dir(imagePath & ActivePresentation.Name & "_" & slideNum & ".jpg") <> ""
Then
Kill imagePath & ActivePresentation.Name & "_" & slideNum & ".jpg"
End If
' now save the slide
ActivePresentation.SlideShowWindow.View.Slide.Export _
FileName:=imagePath & ActivePresentation.Name & "_" & slideNum & ".jpg", _
FilterName:="JPG"
End Sub
这很好,除了它保存到我的电脑上的默认位置。我将把它交给其他人,我需要一个对话框,每次他们试图保存时都会弹出,询问他们要保存的地方。我的所有尝试都包含了Saveas对话框,但都没有成功。如果有人能帮助我,我将不胜感激。感谢
答案 0 :(得分:0)
您可以使用此功能选择文件夹:
Function BrowseForFolder(dialogTitle As String) As String
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Title = dialogTitle
.Show
If .SelectedItems.Count = 0 Then
' Browsing cancelled by user.
BrowseForFolder = ""
Else
BrowseForFolder = .SelectedItems.Item(1)
End If
End With
End Function
因此,不要硬编码imagePath
,而是执行此操作:
imagePath = BrowseForFolder("Save image in this folder...")