当前位置: 代码迷 >> Office >> vba input box的有关问题,麻烦了
  详细解决方案

vba input box的有关问题,麻烦了

热度:706   发布时间:2016-05-05 05:53:15.0
vba input box的问题,麻烦了
我想弹出个input box ,然后根据输入的路径保存文件,怎么还没等我输入呢,文件就处理完了,能不能等inutbox 点OK时,程序再执行,或者有其他方法么??

 Dim s1
    s1 = Range("F1") & ":" & Range("H1")
    Dim tosi As String
    Dim pathT As String
    pathT = ThisWorkbook.Path & "\" & Replace(ActiveWorkbook.Name, ".xls", ".ppt")
    tosi = InputBox("plz input the Power Point file path and name", Title:="Power Point file", Default:=pathT)
                   
  'PowerPoint save
  ppApp.ActivePresentation.SaveAs Filename:=tosi
  
  'Excel sheets copy
  For i = 1 To ThisWorkbook.Worksheets.Count
    ThisWorkbook.Worksheets(i).Range(s1).CopyPicture xlScreen, xlPicture
    'copy to PowerPoint
    Set ppSld = ppPst.Slides.Add(Index:=i, Layout:=12)
    'paste
    ppSld.Shapes.Paste
    'Correction to maximize the PowerPoint chart position and size
    With ppSld.Shapes(1)
      .LockAspectRatio = msoFalse
      .Top = 0
      .Left = 0
      .Height = ppH
      .Width = ppW
    End With
  Next i

------解决方案--------------------
tosi = InputBox("plz input the Power Point file path and name", Title:="Power Point file", Default:=pathT)
 改成
tosi = Application.InputBox("plz input the Power Point file path and name", Title:="Power Point file", Default:=pathT)
  相关解决方案