+ Reply to Thread
Results 1 to 8 of 8

vba get the folder of a file selected from the msofiledialogfilepicker

  1. #1
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    vba get the folder of a file selected from the msofiledialogfilepicker

    this has got to be easy...

    all i want is to know the folder of the file selected in a msofiledialogfilepicker

    everything i have found in the last 2 hours says "use msofiledialogfolderpicker" but i really want my user to be able to select the file and then i need to parse out just the folder part of the filepath...

    no rush, i'm heading out for the evening, will check back on this tomorrow morning.
    Hope I could help - if your post has been solved don't forget to mark it as such.

    Clicking the * below is a great way to say thanks!

    "Drowning in 10 feet of water isn?t any different than drowning in a million feet. And if you can swim, it doesn?t matter how deep the ocean is. At some level, once you realize you?re in water that?s too deep to stand, you have to have a very different approach," - Joi Ito

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,083

    Re: vba get the folder of a file selected from the msofiledialogfilepicker

    Just Googled: Excel 2010 VBA excel 2010 vba msofiledialogfilepicker

    Does this help:

    http://www.wiseowl.co.uk/blog/s209/type-filedialog.htm


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: vba get the folder of a file selected from the msofiledialogfilepicker

    i still haven't figured it out... i feel like that link is just an overview of the msoFileDialogFilePicker and how to use it... I am successfully returning the entire filepath into a variable, all i'm trying to do is separate the folder trail from the filename itself so i can later use the two separately in a "Shell.Application" object... here's that section of code for reference:

    Please Login or Register  to view this content.
    another option might be to separate the pieces of strFile into c:\\folder\subfolder\file.type into strFolder = c:\\folder\folder\ and strFile = file.type, possibly using some combination of left() and right()...

    what i'm really trying to do is figure out the height and width (in pixels) of the selected file, so if anyone knows how to do that any simpler i'm fairly comfortable with the idea of abandoning all this stuff...

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: vba get the folder of a file selected from the msofiledialogfilepicker

    Hi simarui,

    The following functions may help break your folder and file name combination into parts.

    Please Login or Register  to view this content.
    Lewis

  5. #5
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: vba get the folder of a file selected from the msofiledialogfilepicker

    thanks Lewis, i like the InStrRev, good to know that exists. I found this as well:

    Please Login or Register  to view this content.
    and also, which i ended up using:
    Please Login or Register  to view this content.
    so now my code works... but only if I step through it... I'm trying to build an image painter which loops through every pixel of a selected image, and changes an individual cell to that pixel's color. don't ask why...

    at least once in my tests i was able to click on the button, select an image and it painted just fine, but repeating that process a second time usually seems to paint all cells grey. closing the workbook and trying again seemed to fix the issue yesterday but it does not today... if i step through the code however, everything looks like it's working. i spent about 5 minutes painting one line at a time earlier (by adding a break to the next i line) and got halfway through an image, then i removed the break, hit f5 and the window froze for a few minutes, then moved on through the code as if it was working (but it had painted the remainder of the image grey again...)

    any thoughts? workbook attached.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: vba get the folder of a file selected from the msofiledialogfilepicker

    Hi,

    I was able to run your file with similar results. The jpg file I selected was mostly green. The green color was not the same as the color in the original jpg file. The software added 3 bands of gray color.

    I have no idea what causes the problem.

    I had a similar problem about a year ago, when painting colors in a chart. About 50% of the time, places that shouldn't have been painted were painted. In single step mode, everything painted correctly 100% of the time. I was never able to solve that problem.

    I'm sorry I couldn't help more. Thanks for the rep points.

    Lewis
    Last edited by LJMetzger; 05-20-2015 at 12:21 PM.

  7. #7
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: vba get the folder of a file selected from the msofiledialogfilepicker

    Thanks for your help LJ, This has gotten off topic from the original thread. I'm going to mark this post solved and start a new thread to address the new issue.
    Last edited by simarui; 05-21-2015 at 10:12 AM. Reason: This thread is solved.

  8. #8
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: vba get the folder of a file selected from the msofiledialogfilepicker

    so instead of posting another thread i asked the guy next to me and he suggested using "DoEvents" and that seems to have done the trick...

    more info:
    i don't actually understand pretty much anything on this site:
    https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    nor this one, but apparently doevents can be "dangerous"... so be careful i guess??
    http://stackoverflow.com/questions/1...out-being-evil

    ^^my code looks almost exactly like the "don't do this" example near the bottom of that page lol^^

    but anyway, it works now, and maybe DoEvents would help you too? just don't blame me whenever any of the things that guy on stackoverflow warned us about occur... whatever they actually mean.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. msoFileDialogFilePicker: How to show csv and no other file types
    By ninmjj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-09-2013, 09:40 AM
  2. [SOLVED] Display the link of the file from fixed folder when the file is selected from drop down
    By vignesh805 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2013, 06:38 AM
  3. Using Excel built-in dialogs:-msoFileDialogFilePicker, are necessary tools
    By torspake in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-13-2011, 03:42 AM
  4. Replies: 6
    Last Post: 08-11-2006, 03:41 PM
  5. "Folder Select" Dialogue - Opening multiple files from selected folder
    By Rob in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-30-2005, 10:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1