-
Apr 21st, 2007, 01:35 PM
#1
Thread Starter
New Member
Find VBA application path
I have a VBA application to be used in AutoCAD. The application has several data files that must be opened and read by the VBA application. I propose to have users install the files in the folder with the VBA project file. How can I obtain the path to the VBA project executable file?
-
Apr 21st, 2007, 01:48 PM
#2
Re: Find VBA application path
Welcome to the Forums.
Depending on the VBA app you can use either of these to get what you need.
Office:
MsgBox Application.Path
Excel:
MsgBox Application.ThisWorkbook.Path
Word:
MsgBox Application.ActiveDocument.Path
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Apr 21st, 2007, 02:53 PM
#3
Thread Starter
New Member
Re: Find VBA application path
Thanks for the quick response, but the answer did not address what I was seeking. "MsgBox Application.Path" returns he path to the Autocad program. In an Excel VBA application, I believe it would return the path to the Excel program files.
I am seeking a way to determine the path to my VBA code executable, which is a *.dvb file, stored in a folder outside the Autocad or Excel application with which it interacts.
Does anyone know of a way to return this path?
-
Apr 21st, 2007, 03:41 PM
#4
Re: Find VBA application path
I posted other methods too in my previous post. I dont have Autocad so I am not sure what the child object would be but it would probably be similar to the examples I posted for Excel and Word.
Probably something like Application.ActiveDrawing.Path or Application.ThisDrawing.Path?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Dec 29th, 2007, 11:06 PM
#5
New Member
Re: Find VBA application path
Originally Posted by RobDog888
I posted other methods too in my previous post. I dont have Autocad so I am not sure what the child object would be but it would probably be similar to the examples I posted for Excel and Word.
Probably something like Application.ActiveDrawing.Path or Application.ThisDrawing.Path?
It's not going to be directly under the application object; just about everything that's a child of the application object is going to be under the AutoCAD application root dir - not where he wants be - and the VBE object is wonky to access directly. Here's how to do it under AutoCAD 2008 Civil 3d (Also tested with ACAD 2006)
Under AutoCAD VBA, all the vb code runs in the context of the editor, even if it's not visible. Here's how to get the dir you're looking for:
1. Under Tools, add a reference to 'Microsoft Visual Basic for Applications Extensibility 5.3'
2. Get the Dir your VBA app is executing in like so:
Dim objVBE as VBE
Set objVBE = Application.VBE
MsgBox objVBE.ActiveVBProject.FileName
...this will return the complete path of the current VBA app; just knock the file off the end of the string, and you have it.
Peace!!
-
Aug 2nd, 2010, 05:11 AM
#6
New Member
Re: Find VBA application path
Application.CurrentProject.Path
-
Mar 5th, 2011, 11:15 AM
#7
New Member
Re: Find VBA application path
Originally Posted by jy0tsna
Application.CurrentProject.Path
I see you didn't read the above post regarding context.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|