fork download
  1. your text goes herePrivate Sub CommandButton3_Click() 'PPT削除
  2. Const CELL_FILE_PATH As String = "B3"
  3. ' ファイルパス取得
  4. Dim st As String '変数を宣言する
  5. With Application.FileDialog(msoFileDialogFolderPicker)
  6.  
  7. If .Show = True Then
  8. Range(CELL_FILE_PATH).Value = .SelectedItems(1)
  9.  
  10. PPT削除して保存
  11.  
  12. Else
  13. MsgBox "キャンセル実行"
  14. End If
  15.  
  16. End With
  17.  
  18. End Sub
  19. Sub PPT削除して保存()
  20. Dim i As Long
  21. Dim strArray() As String
  22. Dim strFile As String
  23. Dim strPath As String
  24. Dim strBook As String
  25. Dim Path As String
  26. Dim PPT_app As Object
  27. Dim pptx_file As String
  28. Dim ppt_file As String
  29.  
  30. 高速開始
  31. Path = Sheets("Excel").Range("B3").Value
  32.  
  33. strPath = Path & "\"
  34. strFile = Dir(strPath & "*" & ".ppt")
  35. i = 0
  36.  
  37. Do While strFile <> ""
  38. If LCase(Right(strFile, 4)) = ".ppt" Then
  39. ReDim Preserve strArray(i)
  40. strArray(i) = strFile
  41. i = i + 1
  42. End If
  43. strFile = Dir()
  44. Loop
  45.  
  46. If i = 0 Then
  47. MsgBox "pptファイルはありません"
  48. Else
  49.  
  50. Set PPT_app = CreateObject("PowerPoint.Application")
  51. PPT_app.Visible = True
  52.  
  53. For i = 0 To UBound(strArray)
  54.  
  55.  
  56. With PPT_app.Presentations.Open(strPath & strArray(i))
  57. strBook = Left(strArray(i), InStrRev(strArray(i), ".") - 1)
  58. ppt_file = strPath & strArray(i)
  59. pptx_file = strPath & strBook & ".pptx"
  60. .SaveAs Filename:=pptx_file
  61. .Close
  62. End With
  63. Kill ppt_file '元ファイル削除
  64. Next
  65. MsgBox "PPT変換し元ファイルは削除しています"
  66. PPT_app.Quit
  67. End If
  68.  
  69. Set PPT_app = Nothing
  70.  
  71. 高速終了
  72. End Sub
  73.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty