wps无法执行FileDIalog
我在excel用vba写了一段另存代码,在excel中运行正常,但在wps里却总是保存到D盘,而没有弹窗选择部分,即FileDialog不执行,请问这种情况如何解决
代码如下:
'另存为
Sub SaveSheetsAsWorkbook()
Dim myPath, wb As String
Dim sht, sht1 As Worksheet
Dim Nsht As FileDialog '打开保存对话框
Dim iMsg As Integer
Set Nsht = Application.FileDialog(msoFileDialogFolderPicker)
With Nsht
If .Show = -1 Then
' 如果单击了确定按钮,则将选取的路径保存在变量中
myPath = .SelectedItems(1)
End If
End With
Set sht = ThisWorkbook.Sheets("投资费用明细表")
wb = Right(sht.Range("A2"), Len(sht.Range("A2")) - 7)
sht.Copy
On Error Resume Next '有这个文件夹就不创建
MkDir (myPath & "\01 会审纪要及投资费用明细表") '生成文件夹
'保存统计表到指定盘符
ActiveWorkbook.SaveAs fileName:=myPath & "\01 会审纪要及投资费用明细表\" & wb & "—投资费用明细表.xlsx"
iMsg = MsgBox("是否生成信息表?", 4 + 32)
If iMsg = 6 Then
Set sht1 = ThisWorkbook.Sheets("设计信息表")
sht1.Copy
ActiveWorkbook.SaveAs fileName:=myPath & "\01 会审纪要及投资费用明细表" & "\设计信息表.xlsx"
Workbooks("设计信息表.xlsx").Close
Else
Exit Sub
End If
End Sub
创作者俱乐部成员