Solved

Calling documents from users harddrive

Posted on 2001-06-11
5
185 Views
Last Modified: 2010-05-02
Ok,

I need to be able to access several templates in this program.  Currently I call them from "C:/documentlocation".

However, when I package this program, not sure where the documents will be installed (for example, the user may wish to have the program installed on his D: drive).  Is there an easy way to either:
a.  Set location of install at packaging time, so that I can ensure that my templates install to "C:/documentlocation" on the user computer

or, and perhaps better,

b.  Determine where the templates are located on the machine when the program is run, so that the program picks the proper template (and I avoid thoes awful errors)

thanks

(sorry bout low points, but almost out and still got a few ? left to finish the project)
0
Comment
Question by:phred_the_cat
5 Comments
 
LVL 3

Expert Comment

by:jrspano
ID: 6178065
let the user find them the first time and then save off the dir they picked in the registry and look there next time.
0
 
LVL 1

Accepted Solution

by:
ShaneCourtrille earned 50 total points
ID: 6178201
Why not just have them installed by default into a sub directory of your application?

MyApp\Templates

Then you can always be assured that (unless the user has messed up the install) the templates are in the following location:

App.Path & "\Templates"

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6178269
I am with ShaneCourtrille.
jrspano, i would with you too, but i dodn't trust on end-users and we could get some more calls to support service.
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 6178273
here is some code to locate a file...what you can do is put a file name "TEMPLATES.923" or something with them and run this code to get the full path of where the templates are...

us it like this: MsgBox FindFile("c:\", "templates.txt")

GOOD LUCK :)


''''''''''

Declare Function SearchTreeForFile Lib "IMAGEHLP.DLL" _
    (ByVal lpRootPath As String, _
    ByVal lpInputName As String, _
    ByVal lpOutputName As String) As Long
   
Public Const MAX_PATH = 260

Public Function FindFile(RootPath As String, _
    FileName As String) As String
   
    Dim lNullPos As Long
    Dim lResult As Long
    Dim sBuffer As String
   
    On Error GoTo FileFind_Error
   
    'Allocate buffer
    sBuffer = Space(MAX_PATH * 2)
   
    'Find the file
    lResult = SearchTreeForFile(RootPath, FileName, sBuffer)
   
    'Trim null, if exists
    If lResult Then
        lNullPos = InStr(sBuffer, vbNullChar)
        If Not lNullPos Then
            sBuffer = Left(sBuffer, lNullPos - 1)
        End If
        'Return filename
        FindFile = sBuffer
    Else
        'Nothing found
        FindFile = vbNullString
    End If
   
    Exit Function
   
FileFind_Error:
    FindFile = vbNullString
   
End Function
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6179889
Hi!

Here's a file for you over the net.  Simply set the filename or extention (ie. *.tmp) to find out where the files are.

For interest sake, this one scans every and will list every file with the string that you want.  You'll have to know what same string exists in all your template files : )

Download...
http://www.vb-helper.com/Howto/findstr.zip
Description: Search files matching a pattern below a directory for a string (5K)

Thios one lists out all files matching a pattern.

Download...
http://www.vb-helper.com/Howto/search2.zip
Descrition: Search for files matching a pattern and show their total size (3K)

Well, you may want to merg the 2 in case there are 2 folders with different templates (from different programs) but using the same extention.

That's it!

glass cookie : )
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

10 Experts available now in Live!

Get 1:1 Help Now