VBA:如何让此代码只写入 2 位数字的文件名?
我正在使用以下 VBA 代码将 PPT 幻灯片导出为图像。问题在于,对于幻灯片 1 到 9,文件名只有一个字符(例如:“1.png”)。我需要前九张幻灯片的文件名中有两个字符(例如:“01.png”)以匹配后面的幻灯片(例如:“10.png”)。
我怎样才能做到这一点?
提前致谢!
Sub Save_PowerPoint_Slide_as_Images()
Dim sImagePath As String
Dim sImageName As String
Dim oSlide As Slide '* Slide Object
Dim lScaleWidth As Long '* Scale Width
Dim lScaleHeight As Long '* Scale Height
On Error GoTo Err_ImageSave
For Each oSlide In ActivePresentation.Slides
sImageName = oSlide.SlideNumber & ".png"
oSlide.Export sImagePath & sImageName, "PNG"
Next oSlide
Err_ImageSave:
If Err <> 0 Then
MsgBox Err.Description
End If
End Sub
Function sImagePath() As String
sImagePath = ActivePresentaion.Path
End Function
I am using the following VBA code to export PPT slides to images. The problem is that, for Slides 1 through 9, the filenames have only one character (eg: "1.png"). I need for those first nine slides to have TWO characters in their filename (eg: "01.png") to match the later slides (eg: "10.png").
How can I make that happen?
Thanks in advance!
Sub Save_PowerPoint_Slide_as_Images()
Dim sImagePath As String
Dim sImageName As String
Dim oSlide As Slide '* Slide Object
Dim lScaleWidth As Long '* Scale Width
Dim lScaleHeight As Long '* Scale Height
On Error GoTo Err_ImageSave
For Each oSlide In ActivePresentation.Slides
sImageName = oSlide.SlideNumber & ".png"
oSlide.Export sImagePath & sImageName, "PNG"
Next oSlide
Err_ImageSave:
If Err <> 0 Then
MsgBox Err.Description
End If
End Sub
Function sImagePath() As String
sImagePath = ActivePresentaion.Path
End Function
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
Format
即try using
Format
ie