Solved

Any alternative for CurDir?

Posted on 2004-08-22
5
427 Views
Last Modified: 2012-06-27
Good day. I am having a problem with CurDir function, which return the path to current directory. It appeared that it's not reliable. Sometime it will point to the path to my desktop, even though my VB application is at another location.

http://support.microsoft.com/default.aspx?scid=kb;en-us;80611 also discussed about the reliability of CurDir.

Is there an alternative other than CurDir without statically specified the application location (e.g. c:\programgroup\programname) ?

Thanks and hope to hear from you.
0
Comment
Question by:cwchan80
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
Farzad Akbarnejad earned 20 total points
ID: 11867572
Hi,
Use Path property of App object.

App.Path


-FA
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11868445
You should use public or global variable, and when application starts, you should have code like this (remember App.Path)

Public AppPath as String

Sub Main
     AppPath = App.Path
     ......
     Form1.Show
End Sub

0
 
LVL 3

Expert Comment

by:aParser
ID: 11968065
You can also use the Scripting Runtime

Set o = New Scripting.FileSystemObject
Debug.Print o.GetFolder(".").Path

And I recently found a VB2TheMax "Tip of the Day" that helped me:
Get the Command$ value from inside an ActiveX DLL
http://www.devx.com/vb2themax/Tip/18377
...which is based on the GetCommandLine API.  I see no reason why it wouldn't work inside an executable.

I'm wondering if the CurDir points to your desktop when you launch the program from an icon on your desktop.
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 12378247
I think that my comment is correct answer but the Author must decide on correct answer.

-FA
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now