office 2013....請教vba高手.....
問題1)下方哪邊可再做簡化修正?
問題2)在D:\E\A下只有一份PPT,若遇XX月A月報01.ppt就會出現錯誤,要如何修正?
問題3)最下方Call ppt2pdf..好像不能一次轉檔,要如何修正?
直接引用PowerPoint Library內建的另存PDF功能,設定引用項目→「Microsoft PowerPoint 15.0 Object Library」
---------------------------------------------
Private Sub ppt2pdf(ByVal pptFilePath As String, ByVal pdfFilePath As String)
Dim pptApp As New PowerPoint.Application
Dim pptPre As PowerPoint.Presentation
Set pptPre = pptApp.Presentations.Open(pptFilePath, msoFalse, , msoFalse)
pptPre.ExportAsFixedFormat pdfFilePath, ppFixedFormatTypePDF
pptPre.Close
pptApp.Quit
End Sub
----------------------------------------------
Public Sub AA()
Dim FSO As Object
Dim S, xyz1, xyz2 As String
Set FSO = CreateObject("Scripting.FileSystemObject")
S = "D:\E"
If Dir(S, vbDirectory) = "" Then
MkDir (S)
End If
On Error Resume Next
xyz1 = InputBox("請輸入年度yyy:")
xyz2 = InputBox("請輸入月份mm:")
'複製整個目錄
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFolder "Y:\資料\A\" & xyz1 & "年度月報\" & xyz2 & "月", "D:\E\A", True
FSO.CopyFolder "Y:\資料\B\" & xyz1 & "年度月報\" & xyz2 & "月", "D:\E\B", True
FSO.CopyFolder "Y:\資料\C\" & xyz1 & "年度月報\" & xyz2 & "月", "D:\E\C", True
Set FSO = Nothing
Call ppt2pdf("d:\E\A\" & xyz2 & "月A月報.ppt", "d:\E\A\" & xyz2 & "月A月報.pdf")
Call ppt2pdf("d:\E\B\" & xyz2 & "月B月報.ppt", "d:\E\B\" & xyz2 & "月B月報.pdf")
Call ppt2pdf("d:\E\C\" & xyz2 & "月C月報.ppt", "d:\E\C\" & xyz2 & "月C月報.pdf")
End Sub
Recommended article: Chomsky: We Are All – Fill in the Blank.
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.
留言列表