Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

App.Path In VBA...? { Resolved }

What should I use to replace App.Path (from VB) in VBA which is Access Application...?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
App.path - Resolved.
Hello all.
My problem is this.
My program is writing to a settings file which path is described as app.path+"ProgramName.ini"
This directs the program to where it is running from in design-time and to where it's lying in the registry after installation.
All is good except it's a program I want to install in multiple directiories and have every installation refer to its location and not to the latest installed one (because of the registry)

How do I solve this problem?

Thanks, Chen.

App.Path [RESOLVED!]
Ive got a listbox, so when i click on a certain item, i want to open a text file into my textbox. The text files are in a extra folder called Tutorials. Here is what ive been trying to use to open the file:

VB Code:
Open App.Path & "TutorialsCommon Dialog.txt" For Binary As #1Dim scriptText As String: scriptText = Space(LOF(fnum))Get #1, , scriptTexttxtCode.Text = scriptTextClose #fnum

But that doesnt work. I even tried changing For Binary to Input. But it doenst load anything. Any ideas?


Resolved How To Get The DOS App.Path?
I want to call an exe program (written in C) from within my VB application. But it needs the DOS path of the exe file, e.g., C:Progra~1<my application path><my exe file>. The problem is that the App.Path function is returning the windows path which is working only when there is no space in the path, which may not be the case always. Say, for the above example it is C:Program files<my application path><my exe file>. Is there any way to get the DOS App.Path?

One Directory Above App.path (Resolved)
I want to create a file but 1 directory above app.path.

app.path & ???? & " est1.txt"

in unix it would be .. to go to the above directory
what does ???? need to be to achieve this

App.Path Question *Resolved*
Hi, why i am not able to use app.path in my connection

dbCN.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=" & app.path & "usersDB.mdb;" & _
"Uid=admin;" & _

but i will be able to do it if i type the full path replacing the app.path. I am sure my db and the application are in the same folder.

The error i got was undefined variable with app.path highlighted.

RESOLVED Invalid Db Path Name When I Run My App From Cd...?
Hi. Don't really know if this is a vb question but i'm not really sure where else i should ask it........
I've just finished a little vb app and have it saved on my computer under C:SQE. The app accesses a database C:SQEdb1.mdb. I've just put the app on CD and i was wondering if anyone who wants to use it will have to manually save it in the same manner as i did in order to access the database correctly, or is there a way to have the app saved in the correct place on the users computer automatically once they run it? If anyone knows if this can be done and how, or even tell me where if i should be posting this question somewhere else and where, that would be mighty.
Cheers, Triona

App.path Question Can You Help Please?? **RESOLVED**
My program accesses and adds to the database fine when I set the database details via the properties panel of the data control at design time. But if i use the path :

VB Code:
datMapdb.DatabaseName = (App.Path & "mapdb.mdb")

at runtime, then i get the following error:

run-time error '91':
object variable or with block variable not set

Why will this not work?
I need it to as i will be saving my prog on cd and it needs to run from there

Cheers People

MyDocs Path...? (RESOLVED)
How to know My Documents path on Windows XP?


Resolved - Write To A File In The Same Path As App.
I need to do 2 things. My VB6 app currently writes to 3 text files I store in the root of the C: and reads the info back later.
I would like to be able to create a single text file in the same dir as the application is run and store 3 pieces of data in there. I then need to call up the 3 pieces of data at the next program start (form load). Should be pretty easy for those of you with ini file experience but I need a bit of help on this one. Ideally the 3 pieces of info should have whitespace between them (carriage return) for ease of reading.

Thanks in advance

*RESOLVED* How To Put Path Of Application In A Variable?
This is probably a noob question, but i'm still new to vb so please excuse me.

I'm creating just a simple application with just one form with some buttons to open different excel files. My form is thus not much more than a gateway to different .xls files. The users clicks a button and the according .xls file needs to open. The problem is that the .exe file (which opens the form) can be anywhere on the users pc, so i need to know the path so i can make the link to the .xls files.
Does anyone know how i can put the path (of the program) into a variable? i've tried application.path but that just gives me the path to the office folder.
Thanks in advance!


Getting Start In Path From Shortcut *RESOLVED*
does anyone know how to get the start in path that is in the shortcut properties. reason so that if my database is on a server and i make a mapped drive and i put the application on a client that i can put the path of the database in the start in of the shortcut and access the database. i hope this make sense any help would be great. thanx

Persistance Of File Path &lt;RESOLVED&gt;

This is probably a stupid question, but is there an (easy, if possible) way to persistantly store the path to the location of my database in VB?

In my main form I have a button with brings up an open file dialog where the user can select the location of the database which is then stored in a string variable. I want the location to be stored so that everytime a user uses the program the previous db location path is used unless a user wishes to change the location by pressing this button. If they do then this new location becomes the permenantly stored databse location and the next time the program is used this is the pathname that is used to locate the database.

Hope you understand. Is there a way to do this?



FileCopy Statement With App.Path(Resolved)
how would I use the FileCopy statement with App.Path?
Plz Give an example....

*Resolved* How Do I Default A DriveListBox To A UNC Path?
How do I default a DriveListBox to a UNC path?

I would like it to default a DriveListBox to a specific path on our network at startup and we all know drive mappings are never consistent in an office (regardless of what the LAN team tells you!). So I want to default it to a UNC path.

Not really sure how to do this . . .

Do I need to convert the UNC path to friendly path first? If so, what is the easiest way to convert UNC to friendly?

Internet Explorer Path (Resolved)
Does anyone know how to find the path to the iexplore.exe file? I want to shell a new window in IE, but using:

VB Code:
Shell "explorer [url][/url]", vbNormalFocus
Doesn't set focus to the new IE window. It just puts it in the taskbar and flashes it. I just want to have my program find the path to IE, probably somewhere in the registry (I don't know where, and search found too many entries). I just need to find where it's installed, because sometimes people have different paths instead of C:Program FilesInternet Explorer.


*Resolved!* Image Path Problems...
I want to load a small image upon opening the form and have completly messed it up...

The image is called YBC.jpg and the path it is stored in is C:/Program Files/BowlAGE/
I know its simple but I have tried various ways that I can think of and the book I am reading doesnt explain it at all (as far as I can see)

It also has to have an on error if image does not exist..

any help??

I am a VB learner with huge ideas!! push yourself and you shall learn more

First Project: (Forever GROWING!!)

I aim to assist the Ten Pin Bowling Instructors around the world with this!!!!

Edited by - EPOS on 3/15/2005 4:52:56 AM

Get Linked Tables File Path ***RESOLVED
Access may have linked tables.

I want to determine what the linked tables address or file path is from my VB application. Any idea how I could get this?

Getting The File Path Out Of A Common Dialog Box (Resolved)

I've been trying to find a way of populating the URL of my hyperlink control with the file path to documents on my computer. Someone has kindly told me that I need to use a Common dialog box but I have no idea of the code I should use toget the file path out of the box when the user clicks 'OK'.

Does anyone have any suggestions?



Runtime Files In App.Path - {Resolved; In The Negative}
I would like to have a simple VB app to be run directly from a CD.

If I add all the run time files (the only additional component/reference the app uses is the SCRRUN.DLL file) in the applications path, will the app work? If yes do I have to REGSVR32.EXE Filename.ext each of those runtime files?

I can't test the above out 'cause all my machines have VB6.0, or some app made using VB, installed.

Please help

[RESOLVED} Softcoding Db Path In ADODC's PropertyPages
I made a fundamental error in one project by using VB AppWizard to generate my forms because I was in a hurry, and now I am stuck with ADODC hell!

My main problem here is, although I have hardcoded the ADODC's in their Property Pages with my recommended installation path to point to the db, and while I am going a step further and softcoded all ADODC's using the App.Path in my code, what happens when a user will install to a different directory?

Because the ADODcs seem to load before the Form_Load event code is run, they first search for the hardcoded db and then change their pointer to App.Path after Form_Load. I tried placing the App.Path bit in the property pages, it doesn't work.

Anyone who can help, please?


Experience is a bad teacher for its exams precede its lessons.

Edited by - GoodGuy on 8/19/2005 11:32:24 PM

Copy To Some Path With Space Problem ##RESOLVED##
When I'm copying file to directory like this: "C:Program Files" it's just ignores it and not doing anything, because of space in the middle of it, but when I'm trying to copy file to directory like this: "C:Folder" It's working fine and copying the file into it.
any suggestions? Thanks.

Edited by - DDDD on 11/5/2003 6:14:09 AM

{NOT RESOLVED}Keeping Controls/active-x In App.path
When you make your own setup program for your app and it requires the vb6.dll and say the commondialog control i know they can be in %systemroot%system32 but can they if they're on a cd and you want a autorun exe you made but the computer is says win 98 and has vb5 dll not vb6 installed can you keep the dll in the app.path of the exe file? SO you dont have to copy it to %systemroot%system32.


Say my exe file is my own setup program and is on a disk and it has the commondialog control what is the extexnion. Is it .dll or ocx ect?


Tell me if you dont know what you mean i think i explained it a bit unclearly

Edited by - thomas49th on 4/16/2005 4:54:58 AM

DLL Not Found When Launching App, Can Asign A Path Or Not? *RESOLVED*
DLL not found when launching App, can asign a Path or not?

I've created a VB-GroupProject with 2 Projects in this;

1) ActiveX Dll (named ProjectDll.vbp)
   Class Module is named T48RedPlanet.cls
   Dll compiled is named T48RedPlanet.dll
Code :
Option Explicit
Public Function TestText()
TestText = "This Works"
End Function

2) Standard Exe (named ProjectExe.vbp)
   Form is named frmMain.frm
   + 1 TextBox named Text1
   + 1 CommandButton named Command1
Code :
Dim A As T48RedPlanet
Private Sub Command1_Click()
  Set A = New T48RedPlanet
  Text1.Text = A.TestText
  Set A = Nothing
End Sub

Now after Compiling the Dll i've added manually in the ProjectExe the
Dll-Refrence by clicking "Project > References... > ProjectDll > OK".
Then compiled the Exe, everything is in the same folder and works.

The problem i haven is when I cut/paste the Exe and Dll into another folder and
run it it can't find the Dll because it's not in the Path as when i added the refrence manually,
can I put in the Form a code that says the Dll is in the App.Path?

And why is the Dll called "ProjectDll" in the refrence window and
not just "T48RedPlanet.dll" as it's filename I don't understand either?

I'm kinda new in creating Dll's and heard VB-Dll's has limits and it can be written in
C++ for use in VB, but know nothing about C++ (only how to create Icons).
So I hope that anyone can help me out with this prob of the Dll's Path.
Anyway Thnx allready.

Can I add something like "Public Declare Function TestText Lib "T48RedPlanet.dll" ()" to the Form and place the Dll in my the system32 folder?

Tried the next also,

Did put the T48RedPlanet.dll in system32 folder and editted the Form code like this;

Form Code:

Private Declare Function TestText Lib "T48RedPlanet.dll" ()
Private Sub Command1_Click()
Text1.Text = TestText
End Sub

And recieved then the next message:

Run-time erro '453':
Can't find DLL entry point TestText in T48RedPlanet.dll

I'm I getting closer to a solution?

Tried next;


Private Declare Function TestText Lib "T48RedPlanet.dll" Alias "TestTextA" () As Long
Private Sub Command1_Click()
Text1.Text = TestTextA
End Sub

At Runtime I'm not getting an error now , the textbox changed just to empty now and nothing happens.

Edited by - T48 - [RedPlanet] on 10/2/2003 6:59:05 AM

Command() Returns A To Short Filename Path. *Resolved*
Hey everyone, in an project i'm using Command() to recieve the filename path of the file that booted my application, this always worked when i manually did set my app as default application thrue windows, but now i have used a vb function to register my application as default for certain files,

but now i get a value from Command() that retruns something as next;


and i can't get the full filename path back, so my app boots but doesn't open the bootfile, does anyone know why this is or how to solve this?

thanks at front.

aka Red2048.

Edited by - T48 - [RedPlanet] on 3/3/2004 7:12:07 AM

RESOLVED Open Microsoft Files On The Network That Contain Spaces In The Path
undefinedi need the line of code that will allow me to Open Microsoft files on the network that contain spaces in the path, thanks undefined

Detecting Path To System/System32 Folder In Individual Computer. [Un-RESOLVED]
Is there a code in VB to detect the actual path to the computer's system folder.

For example in WinNT system,
it is normally in "C:Winntsystem" and "C:WinntSystem32"
In WinXP .. it is "C:Windowssystem" and "C:WindowsSystem32"

I am not sure in other OS ??? Anyway, the path may not be always the same as user can change the folder name when they install the OS.

I need my software to autodetect which OS it is running in and where are the system folders because I need to dump some files in there.

Currently, what I am doing is to detect whether is there such folder to determine. Is there a better solution then this ?

Please help.

Thanks !

Need To Find .mdb File Name &amp; Path For Each MSACCESS.EXE Proc In Process List*RESOLVED*
I'm hoping someone can help me with this, I've been searching for the last two days & can't find a way to get this.

I have automation PC's each running 5 - 20 different access databases. I'm trying to write a program in vb6 that will take a snapshot of what's running on PC, so that I can more easily restart pc's. I've found a few different ways to get a list of running processes & get some info about each one, like the path to the exe file. I really need to find a way to get the path to the .mdb file. I've tried looping through the related modules & threads with Module32First and Thread32First but neither seem to have the info i'm looking for. I have a feeling this would be trivial in .net, but I don't have that option.


Edited by - tulsa_vbNewb on 10/4/2005 12:45:47 PM

Folder Name From Full Directory Path &"RESOLVED&"
I'm writing a program where I have a form with the Drive, Folder And File list boxes on it and when the user picks a folder it shows all the files in that folder. Then in a text box i want to show JUST the FOLDER name and not the full path....What shows up now is "C:TempProjects" and I just want to have "Projects" in the text box. So I need to know how to cut the full directory path string to just give me the folder name.

The starting path will be different each time because the user needs to pick the starting point. I've attached the code for the form that they pick the folder to store the file in.

Any help would be greatly appreciated.

Code: Private Sub Form_Load()
Drive1.Drive = "C:"
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub

Private Sub Dir1_Change()

    Dim Fullpath As String
    Fullpath = Dir1.Path
    MainView.Text7(6).Text = Fullpath
    File1.Path = Dir1.Path
End Sub

Edited by - skeeley6 on 10/12/2005 4:39:18 PM

;RESOLVED] Get Filename From App.path &amp; &"Myfile?.dat&"
How can i return the filename and the path name from the full path in a filename? Like:

Get A Network Files Local Path From Its UNC Or Mapped Drive Path
After a user browses for a file, if it is a network file I want to get the path that is local to that networked computer. For example if I have a mapped drive named "N:" which maps "\ServerShared" which is "C:Shared" on the server, if a user browses for a file and selectes "N:MyFile.txt" or "\ServerSharedMyFile.txt" I want to get the path that is local to Server, which is "C:SharedMyFile.txt". I have been searching the forum with no luck but if it is out there and you could please point me in the right direction... Thanks!

Mapping Windows System Folder To Application Path(EXE Path)
Dear all,

My problem is this :

I am using an ocx's for flex grid & Image edit for displaying data & images.

I want to keep my EXE file & the supporting files in CD, so that anyone can run this application from CD.

I don't want to do installation package & also not to register the ocx files. Instead of this I'll keep my supporting files along with EXE in CD.

I want to map system folder to my app.path (in CD), so that my application will run taking supporting files in CD rather than windows system folder.

Here I'm stuck.

By doing this I can avoid regestering OCX or developing package.

Please help me to solve this problem.


Dir(path &amp; Filename) Error If Path Is To Cdrom?
i always get an error in my code

Dir(path & filename)
if path is a drive letter for cd rom...
how can i avoid this error?

VB RunTime 76 Invalid Path Name; Path Not Found. Please Help
I am writing an application that the user inputs three things. 1. Path To List 2. Path To Save Text File 3. Name of text file. The user inputs the Path To List and presses the List Files button. Then the user inputs the Path to save the file, and 3rd the name of the file. Then they press transfer which moves the list from the FileListBox to the ListBox and then writes a text file of the list. If the user inputs a nonexisting directory they will get a RunTime 76 error invalid path name; path not found. I was wondering if there was a way to test to see if a directory path is valid. Please Help! any help is extremley appreciated.

Path Not Found Error, But Path Exists
I am getting a path not found error on the highlighted line, but the thing is, the path is found. i tried to debug and the information seems right.

VB Code:
Private Sub cmdSaveFile_Click()    m_strProjectsDirectory = "Projects"    m_strBackupDirectory = "Backups"    m_strSaveProjectFileName = txtFileName.Text    m_strSDPROJFileName = m_strSaveProjectFileName & ".sdproj"    m_strFileNameLocation = App.Path & "" & m_strProjectsDirectory & "" & m_strSDPROJFileName        If Len(Dir$(App.Path & "" & m_strProjectsDirectory & "", vbDirectory)) > 0 Then        'do nothing because the Projects directory exists    Else        MkDir (App.Path & "" & m_strProjectsDirectory & "")    End If        If m_strSaveProjectFileName = vbNullString Then        MsgBox "You must input a filename!", vbExclamation, "Error Encountered."        Exit Sub    ElseIf LCase(Right$(txtFileName.Text, 7)) = ".sdproj" Then        MsgBox "Input your file name, excluding the file extension.", vbInformation, "Error Encountered."        Exit Sub    End If        If FileExists(m_strFileNameLocation) Then        m_intMsgBoxAnswer = MsgBox("The file name that you have specified is already in use." & vbNewLine & _                                   "Would you like to overwrite this file?", vbExclamation + vbYesNo, "File Name in Use.")        If m_intMsgBoxAnswer = vbNo Then            MsgBox "The file has not been overwritten" & vbNewLine & _                   "and has not been saved anywhere.", vbInformation, "File Not Overwritten."            Exit Sub        Else 'If vbYes Then            If Len(Dir$(App.Path & "" & m_strBackupDirectory & "", vbDirectory)) > 0 Then                'do nothing because the backup directory exists            Else                MkDir (App.Path & "" & m_strBackupDirectory & "")            End If                    'copy the file to the backup directory, date and time stamp it so as to prevent file copy            'problems            [hl]FileCopy m_strFileNameLocation, App.Path & "" & m_strBackupDirectory & "" & Date & Time & m_strSDPROJFileName[/hl]                    'delete the file from the original directory            Kill m_strFileNameLocation                    'rewrite the file            WriteProjectFile                        'inform the end user            MsgBox "The file has been overwritten as requested. Please note that" & vbNewLine & _                   "the file was also backed up for you and placed within the" & vbNewLine & _                   "backup directory." & vbNewLine & vbNewLine & _                   "The location of the backup directory is:" & vbNewLine & _                   App.Path & "" & m_strBackupDirectory & "" & vbNewLine & vbNewLine & _                   "The name of the backed up project file is:" & vbNewLine & _                   Date & Time & m_strSDPROJFileName, vbInformation, "File Overwritten."        End If    Else 'file name not in use        WriteProjectFile    End If        Unload MeEnd Sub

Convert UNC Path To Local Drive And Path
I thought there was a way to do this but I can't remember it. Ho can you convert a UNC path back to a local drive and path (mapped or local). I believe there was an API but I can't find it.

ex. \serverdevelopment converts to Z:Development

Find The Path, Enter Path Into String
What I want to do is search for a file on a drive and have
the path name entered into a string... for example pth$

Print #2, "C:"
Print #2, "CD"
Print #2, "CD Program*" < Prob 1
Print #2, "CD America's*" < Prob 1
Print #2, "CD System"
Print #2, "CD Save" < Prob 2
Print #2, "CD save" < Prob 2
Print #2, "DIR /A /O:D > C:" & ID$ & "save.LOG"

Also I have the following problems with the code above.
1. There are two directory's that are named "CD America's"
The problem im having is I canot use spaces and have to use a astrix.
2. Case sensitive for going down directories.


File Path Withouth Application Path
Hi all,

my program uses some sub directories to store data in it. The user can select files through a common dialog (file open) control.

What i need is the location of the file WITHOUT the application path/folder. So something like

app.path = c: estapplication1

filelocation = c: estapplication1files est1.txt

result (what i need) should be then = files est1.txt

Any ideas about this one?



How To Set The Current Drive And Path To A Network Path?
Hi everybody,

In my client's office, there is a Windows 2000 Advanced Server computer and several Windows 98 workstations connected to it. From a workstation computer I want to set the current drive and path to "\ServerServer eMarket". Is that possible without mapping the network drive?

How Can I Conver A Short Dos Path To Windows Path?
How can I conver one of those shortened paths like msdos paths to windows paths (the actual file is not shortened)
(like when you have progra~1 instead of program files)

Convert A Long Path Name To A Short Path Name (8+3)

Does some one could tell me how could i convert a long path name to a short path name (8+3)

For exemple :



Thank you for your help.....

Help With Path Of File / Shell Program Path
Currently I am using the shell command to open an application called Kodakprv.Exe. Their are going to be multiple users for my application and of course the Kodakprv.Exe is in a different directory on each PC. Is their a way to find the directory that the kodakprv.Exe is in and then use that as Path in the shell command to open Kodakprv.Exe. Any help would be greatly appreciated.

Here is the code I have now


sAppName = Trim(strImageName) & " - Imaging Preview"
intRet = Shell("C:Program FilesWindows NTAccessoriesImageVuekodakprv.exe \lightfootd-drivewebsecurescanimages" & strImageName, vbNormalNoFocus)

TEMP Path? System Folder Path?

i need to extract a temporary file onto my clients computers, and i want this file to go to the windows temporary directory, (e.g. c:windows emp or c:winnt emp)

is there a way to find this temp directory on the clients machine and then set that into a string to use? because some operating systems have different paths to their temp directory, my script must be dynamic


Edited by - Ahmz_055 on 12/11/2004 4:59:01 PM

How To Obtain Relative Path From Absolute Path?

How do I obtain the relative path (e.g. "....Test.tmp" ) from the absolute path ( "C:Test.tmp" ) with respect to a directory (e.g. C:Temp2Dir2 )? This should work irrespective of where the file Test.tmp is stored.
Do you have any sample code which could help me do this?

Any help would be greatly appreciated.

Thanks and Regards,

Application Path Or File Path I Am Not Sure
I have a very small exe that is written in vb6.0 It is so small it doesn't require any setup program to run it.

So here is my question. When the user moves the exe to a folder on load I want to display the location of the exe to the user if they request it and to load the proper help files if they have moved them along with the exe.

Does anyone have any sample code of how to do this. I am sure it could be done with an api call, but wouldn't know where to start.

Any help as always is greatly appreciated.


Path Location Problem Dir.path
I have problem here.. i have textbox that store path location. It show in the textbox as C:\ . How I can show in the textbox as C: ?

Dir1.Path = Text1.Text

Getting File Path From Full Path And Name
Let's presume I've got a path as follows :

I want to get :
only, so I don't want the file name.

I tried this :

NewFName = Mid(FName, InStrRev(FName, "") + 1) & "Output"
If Not FoldCreated Then
MkDir NewFName
FoldCreated = True
End If

But, I got the filename?
How can I change this to get the path only??

Network Path To Local Path
I have an application that remotely installs a service in some stations.
I use path: \MachineNameAdmin$ for the installation of the service.
Somebody knows a way to return the local path through \MachineNameAdmin$ ?
Example: Passing \MachineNameAdmin$ would return c:winnt


How To Extract Path From Path+exename ?
Anybody have code that will allow the path to be extracted from the full path of a file , for example,

d:documents and settingsmyypcfile1.exe

well i need to extract just,

d:documents and settingsmyypc


Local Path To Net Path... Simple?
how can i convert:





Copyright 2005-08, All rights reserved