VBA:如何让此代码写入 3 位数的文件名?

发布于 2024-12-15 10:36:27 字数 440 浏览 4 评论 0原文

我使用以下代码从活动 PPT 文件导出 PNG 文件。我发现我需要文件名是三位数字。我需要“001.png”、“002.png”等,而不是“01.png”、“02.png”等。

你能帮助我吗?我尝试过

sImageName = Format(oSlide.SlideIndex, "000") & ".png"

,但没有成功。

导出有效的部分代码:

For Each oSlide In ActivePresentation.Slides
sImageName = Format(oSlide.SlideIndex, "00") & ".png"
oSlide.Export sImagePath & sImageName, "PNG"
Next oSlide

提前谢谢您!

I'm using the following code to export PNG file from the active PPT file. I find that I need the file names to be THREE digits. Instead of "01.png", "02.png", etc., I need "001.png", "002.png", etc.

Can you help me? I tried

sImageName = Format(oSlide.SlideIndex, "000") & ".png"

but that didn't work.

Export section code that does work:

For Each oSlide In ActivePresentation.Slides
sImageName = Format(oSlide.SlideIndex, "00") & ".png"
oSlide.Export sImagePath & sImageName, "PNG"
Next oSlide

Thank you in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情深如许 2024-12-22 10:36:27

您已经找到了解决方案,格式应设置为“000”而不是“00”

此代码在 Powerpoint 2010 中正确运行

Sub Test()
    sImagePath = "C:\Temp\"
    For Each oSlide In ActivePresentation.Slides
    sImageName = Format(oSlide.SlideIndex, "000") & ".png"
    oSlide.Export sImagePath & sImageName, "PNG"
    Next oSlide
End Sub

并生成类似“001.png”的文件名

You have got the solution, the format should be set to "000" instead of "00"

This code runs correctly in Powerpoint 2010

Sub Test()
    sImagePath = "C:\Temp\"
    For Each oSlide In ActivePresentation.Slides
    sImageName = Format(oSlide.SlideIndex, "000") & ".png"
    oSlide.Export sImagePath & sImageName, "PNG"
    Next oSlide
End Sub

and produces file names like "001.png"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文