请问文件夹选择对话框的vba代码,在excel可以运行,但是在wps里面就运行不了?

在wps中运行后就闪了一下,然后回到工作表。没有打开文件夹选择对话框。

Sub Test3()

Dim flg As Office.FileDialog

Dim i As Integer

Set flg = Application.FileDialog(Office.MsoFileDialogType.msoFileDialogFolderPicker)

With flg

If .Show Then

MsgBox "你选择了文件夹:" & .SelectedItems.Item(1)

End If

End With

End Sub

江西省
浏览 632
收藏
2
分享
2 +1
2
+1
全部评论 2
 
平凡之路
解决方法是在Sub 代码前增加禁止屏幕刷新代码 Application.ScreenUpdating = False 即可,亲测可行。 引用自:https://bbs.wps.cn/topic/18769
· 广东省
2
回复
Michael
谢谢,亲测有效!
· 江西省
回复