VBA program path
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
VBA program path

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
bhl
Guest





Posted: Thu Jan 13, 2005 10:04 am    Post subject: VBA program path Reply with quote

Hi

Is it possible to get VBA path from where it was loaded into autocad?

Birger

Back to top
Matt W
Guest





Posted: Thu Jan 13, 2005 6:23 pm    Post subject: Re: VBA program path Reply with quote

You'll need to add a reference to: Microsoft Visual Basic for Applications
Extensibility 5.3
Then add the following code to a module.

Sub test()
Dim VBInstance As VBIDE.VBE
Set VBInstance = ThisDrawing.Application.VBE
MsgBox VBInstance.ActiveVBProject.FileName
End Sub

This will give you the full file name, including the path.

--
I support two teams: The Red Sox and whoever beats the Yankees.

"bhl" <bhl@interconsult.com> wrote in message news:41e61b46_3@newsprd01...
Quote:
Hi

Is it possible to get VBA path from where it was loaded into autocad?

Birger

Back to top
ClementZheng
Guest





Posted: Mon Jan 17, 2005 10:01 am    Post subject: Re: VBA program path Reply with quote

VBE.ActiveVBProject.FileName

Back to top
David Urban
Guest





Posted: Mon Mar 28, 2005 5:44 pm    Post subject: Re: VBA program path Reply with quote

hello

this works when I am only using one VBA program. When I use it then use
another VBA program then back to the program that uses this code it
wants to return the name of the other program. Not good. any suggestions.

David Urban

Matt W wrote:
Quote:
You'll need to add a reference to: Microsoft Visual Basic for Applications
Extensibility 5.3
Then add the following code to a module.

Sub test()
Dim VBInstance As VBIDE.VBE
Set VBInstance = ThisDrawing.Application.VBE
MsgBox VBInstance.ActiveVBProject.FileName
End Sub

This will give you the full file name, including the path.
Back to top
PepaU
Guest





Posted: Tue Mar 29, 2005 5:01 pm    Post subject: Re: VBA program path Reply with quote

Hallo,
you can test a name of your project
(see example)

'gives dvb dir
Public Function getDVBDir(dvbName As String) As String
Dim selDir As String
Dim selFile As String
Dim ipr As Long
On Error Resume Next
For ipr = 1 To Application.VBE.VBProjects.count
If UCase(Application.VBE.VBProjects(ipr).name) = UCase(dvbName) Then
selFile = Application.VBE.VBProjects(ipr).fileName
selDir = predLom(selFile)
getDVBDir = selDir
End If
Next ipr
End Function

Regards
Josef
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB