- UID
- 241790
- 积分
- 51
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-4-11
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
'''这是我在CAD 中 VBA得到主程序所在的目录路径的方法
'''希望大家给兄弟提点意见完善一下.
'''需要参数 VBA程序的文件名
Function PrPath(PrName As String) As String '''得到主程序所在的目录
Dim file_path As String '''文件总路径
Dim i As Integer
For i = 1 To ThisDrawing.Application.VBE.vbprojects.count
file_path = ThisDrawing.Application.VBE.vbprojects.Item(i).FileName
If PathBool(file_path, PrName) = True Then
file_path = Objpath(ThisDrawing.Application.VBE.vbprojects.Item(i).FileName, PrName)
'''得到主程序所在的目录
Exit For
End If
Next i
PrPath = file_path
End FunctionFunction PathBool(FileName As String, PrName As String) As Boolean ''查看程序名是
否为....
If Right(FileName, Len(PrName & ".dvb")) = PrName & ".dvb" Then
PathBool = True
Else
PathBool = False
End If
End Function
Function Objpath(FileObj_Path As String, PrName As String) As String ''''得到路径
Dim path As String
Dim pr_name As String
pr_name = PrName & ".dvb"
path = Mid(FileObj_Path, 1, Len(FileObj_Path) - Len(pr_name))
Objpath = path
End Function |
|