Public Function SaveTo()
On Error GoTo error SaveTo = "" Dim Dname As String Dim comdlg As CommonDialog Set comdlg = New CommonDialog comdlg.Filter = "*.dgn" comdlg.fileName = Dname comdlg.CancelError = True comdlg.ShowSave If Len(comdlg.fileName) = 0 Then Exit Function '保存到文件 If Dir(comdlg.fileName) <> "" Then If MsgBox("文件已存在,是否覆盖?", vbYesNo, "文件已存在") = vbNo Then comdlg.ShowSave End If
' SaveTo = comdlg.fileName Call ActiveDesignFile.SaveAs(comdlg.fileName & ".dgn", True, msdDesignFileFormatV8)
Set comdlg = Nothing Exit Function error: Set comdlg = Nothing Exit Function '用户按了取消
' End Function
[转载Bentley中文知识库原帖] MicroStation迷:请把你的MVBA文件放上来我在我的电脑试一试。
[转载Bentley中文知识库原帖] MicroStation迷:把你的Function改成Sub就能运行了。MicroStation VBA中只有Sub才是可以直接运行的,Function必须被Sub调用才可。
[转载Bentley中文知识库原帖] cmx_stone:不对啊,改了还是不行,在错误发生的电脑上 程序运行到"Set comdlg = New CommonDialog"这句话都会弹出下面这个对话框,可是我CommonDialog控件注册了啊,在我的电脑上程序就能运行:
此主题相如下1.jpg: