Solved

VBA code to ask user to choose source data from a location

Posted on 2016-09-23
5
26 Views
Last Modified: 2016-10-20
Hello experts,

Can anyone provide me a vba code that I use it in a custom button to ask the user to get the source data from a folder / location?

I am trying to create an automate report and the users should be able to choose new raw data from a location.

thanks,
0
Comment
Question by:tony01excel tony
[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 16

Assisted Solution

by:John Tsioumpris
John Tsioumpris earned 250 total points
ID: 41812220
i think you need to read the documentation of FileDialog
Here is small sample in Access VBA
Dim fd As FileDialog
Dim ffs As FileDialogFilters
Set fd = Application.FileDialog(msoFileDialogOpen)
With fd
        Set ffs = .Filters
        With ffs
            .Clear
            .Add "Text RAW", "*.csv", 1
        End With
.AllowMultiSelect = False
        If .show = False Then Exit Sub

FullFilePath = .SelectedItems(1)
End With

Open in new window

0
 
LVL 33

Expert Comment

by:Norie
ID: 41812221
Is the source data a workbook or is it something else?
0
 

Author Comment

by:tony01excel tony
ID: 41812225
Hi Norie,

Source data will be another excel workbook, but saved in the same folder as the automated template.
0
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 250 total points
ID: 41812260
Hi,

pls try

ChDir ActiveWorkbook.Path
strFileToOpen = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*")
If strFileToOpen = False Then Exit Sub

Open in new window

Regards
1
 
LVL 14

Expert Comment

by:frankhelk
ID: 41851710
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- Rgonzo1971 (https:#a41812260)
-- John Tsioumpris (https:#a41812220)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

740 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