473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Browse for a file from a Form

22
Hello, using some VBA I was able to find online, I created a form that displays an image who's file path is stored in a table. The form works great, but I have to manually type the file path into a text box on the form. Is it possible to create a button (and macro??) that opens the normal windows browse for file feature and forwards the file path of the file selected to my text box so that it will automate the process? This seems like something that a lot of folks would like to know how to do. Thanks in advance!
Sep 30 '11 #1
4 2384
NeoPa
32,556 Expert Mod 16PB
Check out Select a File or Folder using the FileDialog Object.
Sep 30 '11 #2
ADezii
8,834 Expert 8TB
The following Code Segment will:
  1. Display the Microsoft Office File Dialog Box
  2. Set Filters to allow only specific Graphic File Formats
  3. Allow only a single File to be Selected
  4. Set the Default File Type for display to Bitmap (*.bmp)
  5. Show the Files in Detail View
  6. Write the Absolute PATH of the File selected to a Text Box named txtImagePath
    Expand|Select|Wrap|Line Numbers
    1. 'First, set a Reference to the Microsoft Office XX.X Object Library
    2.  
    3. Dim strButtonCaption As String
    4. Dim strDialogTitle As String
    5.  
    6. 'Define your own Captions if necessary
    7. strButtonCaption = "Copy Path"
    8. strDialogTitle = "Select Graphic File"
    9.  
    10. With Application.FileDialog(msoFileDialogFilePicker)
    11.   With .Filters
    12.     .Clear
    13.       .Add "Windows Meta Files", "*.wmf"
    14.       .Add "Enhanced Meta Files", "*.emf"
    15.       .Add "Device Independent Bitmaps", "*.dib"
    16.       .Add "Bitmaps", "*.bmp"
    17.       .Add "Icons", "*.ico"
    18.       .Add "Tag Image File Format", "*.tif"
    19.       .Add "PC Paintbrush", "*.pcx"
    20.   End With
    21.   'The Show Method returns True if 1 or more files are selected
    22.     .AllowMultiSelect = False       'Critical Line
    23.     .FilterIndex = 4                'Bitmap files
    24.     .ButtonName = strButtonCaption
    25.     .InitialFileName = vbNullString
    26.     .InitialView = msoFileDialogViewDetails     'Detailed View
    27.     .Title = strDialogTitle
    28.     .InitialFileName = CurrentProject.Path & "\"
    29.   If .Show Then
    30.     Me![txtImagePath] = .SelectedItems(1)
    31.   End If
    32. End With
Sep 30 '11 #3
CharT
22
Thanks so much, I will work on this!

** Edit from later post **
Thank you SOOOOO much :) you both helped me immensely. I am glad there are smart people in this world!
Oct 1 '11 #4
NeoPa
32,556 Expert Mod 16PB
Very pleased to hear it. Good luck with your project :-)
Oct 1 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Richard | last post by:
I have a client who needs to upload the same 7 files twice a week to his web server. FTP is unfortunately not an option as the client is a novice, so I have created an admin interface to his...
23
by: Lamberti Fabrizio | last post by:
Hi all, I've to access to a network file from an asp pages. I've red a lot of things on old posts and on Microsoft article but I can't still solve my problem. I've got two server inside the...
2
by: Anita C | last post by:
Hi, On the click of a button I want to be able to display a dialog so that a file can be picked , the name of which needs to be passed to a function as a parameter in my asp.net app.. However for...
1
by: haf | last post by:
I ahve php file on server that get's information from database.. but i want to take processed php file and get the data form it and disply it in ASP
5
by: Brian Henry | last post by:
I haven't worked much with drag/drop but I am trying to make a form that accepts files to drug onto it from explorer and droped and have the form know the full path and file name of the files...
3
by: den 2005 | last post by:
Hi everybody, I like to allow user to select and browse to which location to save the pdf file of a crystal report viewed on a web page, how can i do this in ASP.Net? I need to get the path...
3
by: ApexData | last post by:
I am using code from the following links to establish a Browse File and Browse Folder dialog. http://www.mvps.org/access/api/api0001.htm http://www.mvps.org/access/api/api0002.htm This code...
4
by: rn5a | last post by:
I am storing the physical path of images, along with 3 more columns, in a MS-Access DB table. I want to provide users the option to change this physical image path (as well as the records in the...
0
by: Darqer | last post by:
Hello There is a possibility to show DownloadFile form in web browser using following peace of code HttpContext context = HttpContext.Current; context.Response.ContentType =...
3
by: prashantdixit | last post by:
Hi, I have a form "FormA" which three browse button and texbox control. There two radio buttons at the top with option option1: Auto option2: Manual These option decides how to select a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.