Excel VBA Macro: Allow User to Select File to Open (with Dialog Box)

  Рет қаралды 13,980

greggowaffles

greggowaffles

2 жыл бұрын

Excel VBA Macro: Allow User to Select File to Open (with Dialog Box). In this video, we go over how to allow a user to be prompted to select a file and then open the selected file. We also change the title and button names in the Dialog Box and specify how many files the user is allowed to select.
Code:
Sub select_file()
Dim FilePicker As FileDialog
Dim mypath As String
Set FilePicker = Application.FileDialog(msoFileDialogFilePicker)
With FilePicker
.Title = "Please Select a File"
.AllowMultiSelect = False
.ButtonName = "Confirm"
If .Show = -1 Then
mypath = .SelectedItems(1)
Else
End
End If
End With
Workbooks.Open Filename:=mypath
End Sub
#ExcelVBA #ExcelMacro

Пікірлер: 23
@anonomyss
@anonomyss 2 жыл бұрын
I just need a quick and simple solution to how to open workbooks and everything I found was so huge and complicated. This was PERFECT for my situation and so easy to follow. Thank you so much!!!!!!!!
@greggowaffles
@greggowaffles 2 жыл бұрын
No problem! So glad to hear that!!
@ryancollins3025
@ryancollins3025 Жыл бұрын
Thanks for the tutorial - helped with a work task and was the least complicated version!
@greggowaffles
@greggowaffles Жыл бұрын
No prob! Glad to hear that!!
@clarencereireyes4130
@clarencereireyes4130 Жыл бұрын
This is awesome!! it helps me with my project. simple explanation but powerful. Thanks for sharing. 😁
@greggowaffles
@greggowaffles Жыл бұрын
So glad to hear that! Thanks for watching!!
@virginiagould3167
@virginiagould3167 2 жыл бұрын
Thank you this is great!
@greggowaffles
@greggowaffles 2 жыл бұрын
So glad to hear that! Thanks for watching!!
@Shiftkeycom
@Shiftkeycom Жыл бұрын
Question- Can you advise on the necessary vba code to create a custom menu? Custom menu would be at top of shortcut menu, include 2 sub menus "Formatting" & "Standard". Each sub menu would include youtube links and local folder links. Appreciate the help.
@user-vr5qg7mw4q
@user-vr5qg7mw4q Жыл бұрын
This was awesome! thank you
@greggowaffles
@greggowaffles Жыл бұрын
Thank you for watching!!
@adarshVernekar-ez5tt
@adarshVernekar-ez5tt 2 ай бұрын
You are great! Code works perfectly fine👍 thank you so much
@greggowaffles
@greggowaffles 2 ай бұрын
Thank you!!
@rajivjoshi3392
@rajivjoshi3392 Жыл бұрын
Thank you.
@greggowaffles
@greggowaffles Жыл бұрын
You’re welcome!
@ldkNsc
@ldkNsc 2 жыл бұрын
Thanks so much for this! I have been searching the web for a week when I stumbled onto your video. It's just what I've been looking for! But is there a way that multiple files can be selected and opened?
@greggowaffles
@greggowaffles 2 жыл бұрын
So glad to hear that. Thanks for watching! Yes, I’ll make a video on that soon, but you would start by setting AllowMultiSelect = True
@rogerferreira1997
@rogerferreira1997 Жыл бұрын
Hi, Very nice tuto. I'm trying to open a CSV file but nothing happen. Do you have a tip for me ? Thanks in advance.
@ricabude
@ricabude 2 жыл бұрын
Hi, thanks for the video, this is exaclty what I need. However, on running your macro I get a message error that "object variable, or block variable, not defined", and the script halts on the line ".Title =....". Macros for windows and macs differ in any way (I'm on a mac)? Do you have any ideas why this is happening? Thanks again for your help
@greggowaffles
@greggowaffles 2 жыл бұрын
No problem! Yeah, the way Mac and windows reference files is different. I’ll make a video for macs soon
@j.reneewilliams8375
@j.reneewilliams8375 2 жыл бұрын
.title = “Please Make One Selection” is causing Run time error ‘91’: Object variable or with Block variable not set. (Just in case it matters, I am on a MacBook Pro). Thx
@greggowaffles
@greggowaffles 2 жыл бұрын
You’ll have to use different code for a MacBook. I’ll make a video specifically for that
@JimHearn
@JimHearn 4 ай бұрын
@@greggowaffles , did you ever make the video for MacBook for this same code? I could really use it as I am getting the same error.
Copying Data from User Selected Files Using GetOpenFilename
10:26
Excel Macro Mastery
Рет қаралды 18 М.
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 100 МЛН
Became invisible for one day!  #funny #wednesday #memes
00:25
Watch Me
Рет қаралды 52 МЛН
DO YOU HAVE FRIENDS LIKE THIS?
00:17
dednahype
Рет қаралды 80 МЛН
6 Excel Tools Most Users Never Think to Use (Files Included)
12:34
MyOnlineTrainingHub
Рет қаралды 109 М.
Excel VBA UserForm Browse for File to Attach
10:57
SyntaxByte
Рет қаралды 12 М.
Loop Through All Files in a Folder Using VBA/Macros in Excel
13:41
Save As Dialog to Save a Workbook in Excel VBA
17:08
Computergaga
Рет қаралды 31 М.
VBA to BROWSE & COPY Data from SELECTED File in Excel
10:00
Leila Gharani
Рет қаралды 322 М.
Excel Macro and VBA Extract the filename of a file in a Folder
10:07
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 100 МЛН