To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Office Development

Reply Post New Thread
 
Thread Tools Display Modes
Old Apr 21st, 2007, 01:35 PM   #1
Dan Fisher
New Member
 
Join Date: Apr 07
Location: Southern California
Posts: 2
Dan Fisher is an unknown quantity at this point (<10)
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?
Dan Fisher is offline   Reply With Quote
Old Apr 21st, 2007, 01:48 PM   #2
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,875
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
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
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
RobDog888 is offline   Reply With Quote
Old Apr 21st, 2007, 02:53 PM   #3
Dan Fisher
New Member
 
Join Date: Apr 07
Location: Southern California
Posts: 2
Dan Fisher is an unknown quantity at this point (<10)
Arrow 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?
Dan Fisher is offline   Reply With Quote
Old Apr 21st, 2007, 03:41 PM   #4
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,875
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
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
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
RobDog888 is offline   Reply With Quote
Old Dec 29th, 2007, 10:06 PM   #5
Scatterblak
New Member
 
Join Date: Dec 07
Posts: 1
Scatterblak is an unknown quantity at this point (<10)
Re: Find VBA application path

Quote:
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!!
Scatterblak is offline   Reply With Quote
Old Aug 2nd, 2010, 05:11 AM   #6
jy0tsna
New Member
 
Join Date: Aug 10
Posts: 1
jy0tsna is an unknown quantity at this point (<10)
Re: Find VBA application path

Application.CurrentProject.Path
jy0tsna is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Office Development


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:25 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.