View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
Patrick Molloy Patrick Molloy is offline
external usenet poster
 
Posts: 1,049
Default Still more on loading a .CSV into a .XSLS part 5

I don't get Detail view - so I'd guess that the user will see whatever File
Exploder has as default or maybe was last set to?
So consistent? No.

"Paul H" wrote in message
...
Thanks Patrick,

It worked! It showed the correct folder. But how did it know to use
"detail" view? Will that be consistent?

I've modified the web page www.verifycharges.com/Excel1/sample1.htm and
added files to the c:\aaa folder.

Now if I can make the button point to the correct macro and execute it,
I'm done.

Paul


"Patrick Molloy" wrote in message
...
?

your link suggests that you want to set the file path to the folder ....

your code is incorrect ...

you have

ChDrive = "C"

it should be

ChDrive "C"

so

ChDrive "C"
ChDir "C:\Temp"
myFileName = Application.GetOpenFilename("CSV Files, *.CSV",, "Pick a
File")




"Paul H" wrote in message
...


================================================== ========

Please show me what you suggest I try, and I will try it.

================================================== ========

"Patrick Molloy" wrote in message
...
no "="
use
ChDrive "C"

================================================== ========


"Paul H" wrote in message
...

================================================== ========

Joel or Shane, click on this link to a long web page that I created to
show
screen-print examples of my progress.

www.verifycharges.com/Excel1/sample1.htm

================================================== ========

"Joel" wrote in message
...
I'm not sure I understand your problem. Do you wan to only display the
files
in a certain folder? You can use a listbox and manually fill the list
box
with the items in one folder. I believe if you use a win32 object you
can
lock the dialog to display only one folder.

If you want to set a default folder then use the filedialog method
instead
of GetOpenFilename. See VBA help

================================================== ========

"Paul H" wrote:



Shane, will you show me what to specify if my files are in C:\aaa but
I
cannot change from the folder where I am running my programs? Your
help
explanation is not clear. My actual path will be much more complex,
involving a mapped drive, but the C:\aaa example should set me right.

"Shane Devenshire" wrote
in
message ...
Hi,

I don't have time to try to follow all the earlier stuff in this
thread,
however the line

myFileName = Application.GetOpenFilename("CSV Files, *.CSV",, "Pick a
File")

gets both the file name and path, so you just put myFileName in where
ever
you need it.

As you can see I made a change to this line, not because it affect
anything
it just makes it easier to display on one line here. It also shows
that
the
argument name is not technically necessary, in which case you must put
the
arguments in the correct order.

Here is the Help explanation:

Displays the standard Open dialog box and gets a file name from the
user
without actually opening any files.

expression.GetOpenFilename(FileFilter, FilterIndex, Title, ButtonText,
MultiSelect)
expression Required. An expression that returns an Application
object.

FileFilter Optional Variant. A string specifying file filtering
criteria.

This string consists of pairs of file filter strings followed by the
MS-DOS
wildcard file filter specification, with each part and each pair
separated
by
commas. Each separate pair is listed in the Files of type drop-down
list
box.
For example, the following string specifies two file filters€” text and
addin:
"Text Files (*.txt),*.txt,Add-In Files (*.xla),*.xla".

To use multiple MS-DOS wildcard expressions for a single file filter
type,
separate the wildcard expressions with semicolons; for example,
"Visual
Basic
Files (*.bas; *.txt),*.bas;*.txt".

If omitted, this argument defaults to "All Files (*.*),*.*".

FilterIndex Optional Variant. Specifies the index numbers of the
default
file filtering criteria, from 1 to the number of filters specified in
FileFilter. If this argument is omitted or greater than the number of
filters
present, the first file filter is used.

Title Optional Variant. Specifies the title of the dialog box. If
this
argument is omitted, the title is "Open."

ButtonText Optional Variant. Macintosh only.

MultiSelect Optional Variant. True to allow multiple file names to
be
selected. False to allow only one file name to be selected. The
default
value
is False

Remarks
This method returns the selected file name or the name entered by the
user.
The returned name may include a path specification. If MultiSelect is
True,
the return value is an array of the selected file names (even if only
one
filename is selected). Returns False if the user cancels the dialog
box.

This method may change the current drive or folder.

Example
This example displays the Open dialog box, with the file filter set to
text
files. If the user chooses a file name, the code displays that file
name
in
a
message box.

fileToOpen = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If fileToOpen < False Then
MsgBox "Open " & fileToOpen
End If



--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Paul H" wrote:


================================================== =======

Dave,
Thank so much. It works perfectly. I just need to tell it what
folder
to
be looking in, to make the file selection. It will be a long path
on a
networked drive.
I bought a book that should help me figure these things out myself -
Excel
2007 Power Programming with VBA (Mr. Spreadsheet's Bookshelf) by
John
Walkenbach.
Paul