macula 发表于 2005-8-11 20:19:00

[VBA]如何的到.dvb文件的路径?

VBA中,一个函数如何获取它本身所在的.dvb文件的路径?
如函数:function aPath() as string   存在于 d:\bbb\a.dvb 文件中,
则aPath 函数返回 "d:\bbb"?

王咣生 发表于 2005-8-11 22:23:00

在AutoCAD2004下:
'取得当前应用程序路径
Private Function GetDvbPath() As String
    On Error Resume Next
    Err.Clear
   
    Dim strFilePath As String
    Dim strFileName As String
   
    strFileName = VBE.ActiveVBProject.FileName
    If Err Then
      strFilePath = ""
    Else
      Dim pos As Integer
      pos = VBA.InStrRev(strFileName, "\", -1, vbTextCompare)
      strFilePath = VBA.Left(strFileName, pos - 1)
    End If
    GetDvbPath = strFilePath
   
End Function

macula 发表于 2005-8-14 17:58:00

明白了!多谢赐教!

sccat 发表于 2006-4-19 22:20:00

如果是lsp文件呢?
页: [1]
查看完整版本: [VBA]如何的到.dvb文件的路径?