Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 01-17-2014, 02:53 PM
BobBridges's Avatar
BobBridges BobBridges is offline Open Folder in Excel 2010 VBA Windows 7 64bit Open Folder in Excel 2010 VBA Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Ah. Yeah, recording the macro won't help you learn to use the file-open dialogue.

But if I just write a snippet of code for you, that probably won't help you either, because you won't understand how to plug it into the program you already have. I mean, that link I gave you had code examples; presumably you glanced at them and knew they wouldn't help because you don't know enough to adapt them to your program. I don't see how I can do any better, from that angle.

The best I can do is teach you how to write it. I'm willing, but are you? If not, maybe you have a coworker who can?

Let me remind myself how it works and then give you a sample or two. ....Well, maybe it's simpler than I remembered. The most basic way to use it is simply to say
Code:
filename=Application.GetOpenFilename
Plug that into your program and run it to see what happens. If the user selected a file and hit the Open button, the file path and name come back and end up in the variable. If the user hit the Cancel button, you get back the False value. There's a warning in the documentation that the dialogue may change the "current directory"; that's because this version of the dialogue starts in the current directory and the user has to navigate if the file he wants is in a different folder.

So that's the first complication: If the current directory isn't when the desired files are, your program should probably set the current directory before calling the dialogue.

There are other wrinkles you can incorporate. You can set it so it displays just .xlsx files, for example. There's also a setting that lets the user select more than one file, though I gather that isn't what you need in this case. And if you need the user to point to a folder instead of a file, it requires a different dialogue. But that's the general idea.

If you want to understand more than that, I'm willing to explain. But it kind of requires you to learn more VBA. Some people like that idea, some don't. Up to you; I used to sneer at people who don't want to learn, but eventually I decided that if everyone wanted to learn there'd be no one left to do the actual work, so I'm content now.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Office 2010 Can't Open Or Save Documents in My Documents Folder trippb Office 1 07-12-2013 07:29 AM
Cannot open folder in Outlook marketshare Outlook 0 03-17-2013 04:07 PM
Open Folder in Excel 2010 VBA Set a task folder to open as default ghumdinger Outlook 1 07-03-2011 05:34 AM
Open Folder in Excel 2010 VBA Outlook slow to open folder rtankersley Outlook 1 09-16-2008 05:42 AM
OPEN FOLDER starts a search Gwyn Word 0 02-22-2006 06:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:10 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft