Solved

Calling documents from users harddrive

Posted on 2001-06-11
5
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

752 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