View Single Post
  #21   Report Post  
Posted to microsoft.public.excel.programming
Kevin E. Kevin E. is offline
external usenet poster
 
Posts: 16
Default Microsoft Common Dialog control, version 6.0

I used the Application.GetOpenFilename and it worked beautifully, thanks for
your help and suggestions. Seeing as how I am pretty new to programming I am
going to have to play around with the code to see how and where I can use it
more often.

"Tom Ogilvy" wrote:

Let's look at the score Kevin

1 person in "some other forums" talked about the common dialog and I assume
was talking either about VB6 or knew less about Excel than you.

4 people in a specific excel forum have suggested

Application.GetOpenFilename()

Just to add to the non-API choices, if you are using and will only use
Office XP or Office 2003, then you also have a file dialog

----------------------------------

Returns a FileDialog object representing an instance of the file dialog.

expression.FileDialog(fileDialogType)
expression Required. An expression that returns one of the objects in the
Applies To list.

fileDialogType Required MsoFileDialogType. The type of file dialog.

MsoFileDialogType can be one of these MsoFileDialogType constants.
msoFileDialogFilePicker Allows user to select a file.
msoFileDialogFolderPicker Allows user to select a folder.
msoFileDialogOpen Allows user to open a file.
msoFileDialogSaveAs Allows user to save a file.

Example
In this example, Microsoft Excel opens the file dialog allowing the user to
select one or more files. Once these files are selected, Excel displays the
path for each file in a separate message.

Sub UseFileDialogOpen()

Dim lngCount As Long

' Open the file dialog
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = True
.Show

' Display paths of each file selected
For lngCount = 1 To .SelectedItems.Count
MsgBox .SelectedItems(lngCount)
Next lngCount

End With

End Sub

--
Regards,
Tom Ogilvy


"NickHK" wrote:

Kevin,
Check out Application.GetOpenfilename in the VBA Help. That's the easiest
way.
"OP"=Original Poster, the person that started this thread. i.e. You

NickHK

"Kevin E." ...
Ok before people start duking it out here let me explain what I want to do
(reckon I should have done that right off the bat). I want a button on my
user form for the user to click to open a window to a directory to browse
for
a file, then after said user selects the File he/she wants, the File path
will then show up in a text box. I started learning Visual Basic 2005 but
did not realize that VBA in Excel and Autodesk Inventor revolves around VB
6.
VB 2005 has a OpenFileDialog option in the button control and I didn't see
it in VB 6 so I did some checking in some other forums and someone came
back
with the common dialog control. Oh and by the way, what is an "OP".
Thanks
for all the help and suggestions.

"Dave Peterson" wrote:

No, not personally.

In that other thread, your approach seemed like a reasonable approach to
me,
too. But then I thought if there was other stuff in that text (not
always 4
numeric elements), then why revisit it again when the followup post
showed up.

In fact, I used application.trim() in the "white space" suggestion
<still--not
taken personally, but maybe my sense of humor is not coming through.

And in this thread, it just looked to me like the OP was ignoring your
first
suggestion out of hand. I was just trying to get him to review his
requirements.

Maybe I should have started with: "As Tom wrote, ...." just to make it
clearer.


Tom Ogilvy wrote:

There's no accounting for taste. Why have a 4 element array with no
loops
when you can have a 40 element array to loop through. Sounds like your
taking this personally. I was really just suggesting to use
application.Trim before split to eliminate all the wasted elements of
the
array - seems reasonable to me.

--
Regards,
Tom Ogilvy

"Dave Peterson" wrote in message
...
But the OP did seem to ignore that part of your post.

Tom Ogilvy wrote:

I didn't exlude essential content!!

--
Regards,
Tom Ogilvy

"Dave Peterson" wrote in message
...
I was trying to ask the same question as your followup--with more
white
space!

Tom Ogilvy wrote:

Wow. Deja Vu all over again

If I was suggesting that as a solution, I would suggest
consulting the
help
so the OP knows they only return the selection and don't perform
the
action.

--
Regards,
Tom Ogilvy

"Dave Peterson" wrote in message
...
If you want to get a filename of an existing file (to open
later?),
use
application.getopenfilename().

If you want to get a filename to use when you save later, use
application.getsaveasfilename().

If you're doing one of these two, you'll be surprised how easy
it'll
become.

Kevin E. wrote:

I'm extremely new to programming so I don't understand how to
use
the
Windows
API to control the common file dialog.

"Tom Ogilvy" wrote:

if you just want to show the file open or file saveas dialog
use

application.GetOpenfileName()

application.GetSaveAsFilename()

instead.

see help for details.

if you must use the common controls, then use the Windows
API to
control it
rather than the activex control.

--
Regards,
Tom Ogilvy


"Kevin E." wrote:

When working in VBA I try to add the Microsoft Common
Dialog
Control
to my
toolbox but when I try to use it I get a message box
telling me
"The
Control
Could Not Be Created Because It Is Not Properly Licensed".
I
tried
searching
the Microsoft Knowledge Base and Found a utility to fix
this in
VB6
but
didn't work in my situation becuase I don't have VB 6
installed,
just
the
VBA. Any thoughts, or suggestions would be greatly
appreciated.
Thanks

--

Dave Peterson

--

Dave Peterson

--

Dave Peterson

--

Dave Peterson