Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA DriveList / DirList Controls??

I've been working on a project in VBA, and what its doing is reading an
excel file and writing out a fixed format text file using some of the
data in the excel file. I'm writing out the text file using the # Print
Statement.

What I need is a way to specify the drive and path for the text file
that will be output. If it were straight VB I could use the DriveList
and DirList controls, but I cannot seem to find an equivalent in VBA.

I don't believe Common Dialog Control will work either because I'm not
saving the excel file. I'm taking data from the excel file and writing
it to the text file. The Cdlg will save the excel file after the dialog
box is closed.

Does anyone know if those controls exist in VBA? And if not, is there a
suggested work around?


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA DriveList / DirList Controls??

Could you not use GetSaveAsFileName method which would throw up a dialog box
that the user could navigate through the folders and specify the file name.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"junkboy " wrote in message
...
I've been working on a project in VBA, and what its doing is reading an
excel file and writing out a fixed format text file using some of the
data in the excel file. I'm writing out the text file using the # Print
Statement.

What I need is a way to specify the drive and path for the text file
that will be output. If it were straight VB I could use the DriveList
and DirList controls, but I cannot seem to find an equivalent in VBA.

I don't believe Common Dialog Control will work either because I'm not
saving the excel file. I'm taking data from the excel file and writing
it to the text file. The Cdlg will save the excel file after the dialog
box is closed.

Does anyone know if those controls exist in VBA? And if not, is there a
suggested work around?


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default VBA DriveList / DirList Controls??

Set a reference to the "Microsoft Shell Controls And Automation"
library, and then use code like the following:



Dim SH As Shell32.Shell
Dim Fldr As Shell32.Folder2
Set SH = New Shell32.Shell

Set Fldr = SH.BrowseForFolder(0, "Pick A Folder", 0, "C:\")
If Fldr Is Nothing Then
MsgBox "You clicked cancel"
Else
MsgBox "You chose: " & Fldr.Self.Path
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"junkboy " wrote in
message ...
I've been working on a project in VBA, and what its doing is

reading an
excel file and writing out a fixed format text file using some

of the
data in the excel file. I'm writing out the text file using the

# Print
Statement.

What I need is a way to specify the drive and path for the text

file
that will be output. If it were straight VB I could use the

DriveList
and DirList controls, but I cannot seem to find an equivalent

in VBA.

I don't believe Common Dialog Control will work either because

I'm not
saving the excel file. I'm taking data from the excel file and

writing
it to the text file. The Cdlg will save the excel file after

the dialog
box is closed.

Does anyone know if those controls exist in VBA? And if not, is

there a
suggested work around?


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA DriveList / DirList Controls??

Thanks, Bob!

GetSaveAsFileName was exactly what I was looking for. I don't know why
I didn't find that.

Thanks so much!


---
Message posted from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveX Controls leerem Excel Discussion (Misc queries) 0 December 11th 08 01:11 PM
keyboard controls Leslie Excel Discussion (Misc queries) 4 August 12th 08 11:24 PM
using gui controls daddy260 Excel Discussion (Misc queries) 4 May 25th 07 07:35 AM
ActiveX Controls vs Form Controls Alex Excel Discussion (Misc queries) 1 January 11th 06 08:46 AM
Additional Controls Bill Lunney Excel Programming 0 July 29th 03 04:43 PM


All times are GMT +1. The time now is 09:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"