|
|
#1 |
|
New Member
Join Date: Apr 07
Location: Southern California
Posts: 2
![]() |
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?
|
|
|
|
|
|
#2 |
|
Super Moderator
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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, 2007, 2008, 2009, 2010 Office Development FAQ (VBA, VB 6, VB.NET, C#) Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster) If a post has helped you then Please Rate it! • Star Wars Gangsta Rap • Reps & Rating Posts • VS.NET on Vista (New) • Multiple .NET Framework Versions (New) • 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 Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007 |
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 07
Location: Southern California
Posts: 2
![]() |
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? |
|
|
|
|
|
#4 |
|
Super Moderator
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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, 2007, 2008, 2009, 2010 Office Development FAQ (VBA, VB 6, VB.NET, C#) Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster) If a post has helped you then Please Rate it! • Star Wars Gangsta Rap • Reps & Rating Posts • VS.NET on Vista (New) • Multiple .NET Framework Versions (New) • 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 Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007 |
|
|
|
|
|
#5 | |
|
New Member
Join Date: Dec 07
Posts: 1
![]() |
Re: Find VBA application path
Quote:
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!! |
|
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|