[VBA]如何的到.dvb文件的路径?
<P>VBA中,一个函数如何获取它本身所在的.dvb文件的路径?</P><P>如函数:function aPath() as string 存在于 d:\bbb\a.dvb 文件中,</P>
<P>则aPath 函数返回 "d:\bbb" ?</P>
reply
<P>在AutoCAD2004下:</P><P>'取得当前应用程序路径<BR>Private Function GetDvbPath() As String<BR> On Error Resume Next<BR> Err.Clear<BR> <BR> Dim strFilePath As String<BR> Dim strFileName As String<BR> <BR> strFileName = VBE.ActiveVBProject.FileName</P>
<P> If Err Then<BR> strFilePath = ""<BR> Else<BR> Dim pos As Integer<BR> pos = VBA.InStrRev(strFileName, "\", -1, vbTextCompare)<BR> strFilePath = VBA.Left(strFileName, pos - 1)<BR> End If</P>
<P> GetDvbPath = strFilePath<BR> <BR>End Function</P> 明白了!多谢赐教! 如果是lsp文件呢?
页:
[1]