PDA

View Full Version : Solved: Using msoFileDialogFilePicker



ccRider246
02-26-2010, 03:55 PM
I have an excel app that runs in userforms. I am using a filedialog to pull up an msoFileDialogFilePicker where a user will navagate to a file and select it. I don't want them to open it. I am just taking the path and storing it in a textfile so the program knows where to locate the file when it needs it programatically. The problem I have run into is that sometimes the user will double click the file in the file dialog box instead of just selecting it. Now I can tell them to just select it but there is a good chance that a percentage of folks are going to get trigger happy and double click it anyway.
My question - is there a way to prevent the user from opening a file if they accidentally double click it? I have been looking through the properties of the file dialog and don't seem to see one. I was hoping someone might have a clue how I could do this.

Thanks in advance.

Chris

lucas
02-26-2010, 04:11 PM
So what happens when they select a file and hit ok on the filepicker?

ccRider246
02-26-2010, 04:48 PM
When they select a file and hit ok, the path to the file is saved in a text file on their computer in a file called AcctFilePath.dat. On future calls to update the customer list in their pricing application, the code first looks for this path file and follows it to the account list. It opens the account list file, verifies the content, and updates a 2 dimensional array in the application containing all the customers and their pertinent data. That array is used to populate a listbox from which the user can select a customer in order to populate a quote form header. Since they do many quotes during the time that they have this application open, saving the data in an array is sufficent and quick. they have the opportunity to update the array during their use if they think it may need it but in reality that database won't change too often. Every time they open the excel application and wish to make a quote, they make one call to the account list and all the accounts (there are only ±270) are held in memory.

The purpose of saving the aco**** path is so that they don't have to use the file picker each time. If for some reason the file is not at the end of the path, a new picker is brought up.

This may sound a bit backward and I suppose it is but it's what I have to work with so I will make due. If I can figure out a way to kill the opening of a file it will pretty much solve my problem of an accidental opening. I can't have the users opening the account list file and trying to change info in it. When the code accesses the file it is read only and only long enough to populate an array. But if they are allowed to open the file accidentally, they may start screwing around with the information.

Make sense?

Chris

lucas
02-26-2010, 04:57 PM
I just don't understand why the doubleclick action is different than if they click ok on the dialog.

If you run this, it does one thing, open a msgbox. Doesn't matter if they click ok or double click the file.

Sub UseFileDialogOpen()
Dim lngCount As Long
' Open the file dialog
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Show
' Display paths of each file selected
For lngCount = 1 To .SelectedItems.Count
MsgBox "You have selected " & _
.SelectedItems(lngCount)

Next lngCount
End With
End Sub

ccRider246
02-26-2010, 05:13 PM
I just don't understand why the doubleclick action is different than if they click ok on the dialog.
I'm not an expert at this but I thought msoFileDialogFilePicker only allows the user to pick a file. You need to use msoFileDialogOpen for it to open a file when you press OK. At any rate, that's how my program functions with the use of msoFileDialogFilePicker. It does not open the file, it only captures the path.

I think one alternative might be to use folderpicker. I am going to play with that now.

Chris

lucas
02-26-2010, 05:22 PM
folder picker will not show the files.

I'm confused. If you run your filepickerdialog can you double click on the file and open it?

ccRider246
02-26-2010, 05:35 PM
Lucas,
All's well. I took someone else's word that double clicking that file caused it to open in my picker. That is what happens when you're trying to work with people 1000 miles away by telephone. I did not do my due diligence. I never went back and actually checked to see if it did what he said.

I apologize for wasting your time. It did not open the file. It did exactly as it was supposed to do, save the path and return to my app. Thanks for your responses. Had it not been for you I would have been stumbling over this all weekend. That will teach me to trust with verification.

Thanks,

Chris
:beerchug:

lucas
02-26-2010, 05:37 PM
Glad to help Chris. Helps to hash it around sometimes.

Be sure to mark your thread solved please using the thread tools at the top of the page to keep others from reading the entire thread just to find it's been resolved.

Have a good weekend.

ccRider246
02-26-2010, 05:43 PM
Will do, you have a great one, too. I love working from my home but I do miss not having others around to help work through these sorts of things. I know I have lost a lot time doing something one way and getting almost done when I have a epiphany and change horses in the middle of a stream.
I frequented this site a few years back under a different user name and it was always a great help. I got away from it for a while and forgot my user name and password so just ended up with a new account. you guys are a wealth of information.
Thanks again,
Chris

coxonitus
04-22-2011, 10:13 AM
hi,
i'm looking through your posts and maybe one of you guys could help me out.

i wil try to explain mij problem.
i have a dashboard, when i click a button i have to give a password.
When password correct it has to open some sort of pop-up which gives me only the folders i want to choose, when i click a folder it opens the excel file.

in my case, when password correct it opens the pop-up in windows. that means it give's me the searcher of "C": drive. All i want is a local searcher or else the password i gave has no function.

someone??

GTO
04-22-2011, 10:27 AM
hi,
i'm looking through your posts and maybe one of you guys could help me out.

i wil try to explain mij problem.
i have a dashboard, when i click a button i have to give a password.
When password correct it has to open some sort of pop-up which gives me only the folders i want to choose, when i click a folder it opens the excel file.

in my case, when password correct it opens the pop-up in windows. that means it give's me the searcher of "C": drive. All i want is a local searcher or else the password i gave has no function.

someone??

Greetings coxonitus,

I believe you are trying to solve what you are already pursuing in http://www.vbaexpress.com/forum/showthread.php?t=37155

I admire your tenacity and hope you don't give up. That said, I think it would be less confusing for anyone helping, to stay with your original thread. If you find another thread that seems close, you could provide a link to it in your thread.

Just a member here, so certainly just a suggestion; but I think that would help.

I also posted a question (or actually, am about to) in your thread.

Mark