Solved

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

Posted on 2016-09-23
5
22 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
5 Comments
 
LVL 13

Assisted Solution

by:John Tsioumpris
John Tsioumpris earned 250 total points
Comment Utility
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
Comment Utility
Is the source data a workbook or is it something else?
0
 

Author Comment

by:tony01excel tony
Comment Utility
Hi Norie,

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

Accepted Solution

by:
Rgonzo1971 earned 250 total points
Comment Utility
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 13

Expert Comment

by:frankhelk
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Modern/Metro styled message box and input box that directly can replace MsgBox() and InputBox()in Microsoft Access 2013 and later. Also included is a preconfigured error box to be used in error handling.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

763 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

11 Experts available now in Live!

Get 1:1 Help Now