?
Solved

code for browse to specific location.

Posted on 2004-08-12
4
Medium Priority
?
151 Views
Last Modified: 2010-05-02
In my VB6 application, I need a code to insert in the command button. This button should pop the save as window and I should have the option to browse to specific location. Just like save as window in MS excel or MS work.

Thank you.
0
Comment
Question by:Aiysha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 1000 total points
ID: 11787885
under project/components... select MS Common Dialog Control.
Place this control on your form, then:

Private Sub Command1_Click()
    CommonDialog1.ShowSave
    MsgBox CommonDialog1.FileName
End Sub
0
 
LVL 13

Assisted Solution

by:Michael_D
Michael_D earned 1000 total points
ID: 11788164
Here is the code that do everithing you need :)


Private Sub Command1_Click()
  ' Set CancelError is True
  CommonDialog1.CancelError = True
  On Error GoTo ErrHandler
  ' Set flags
  CommonDialog1.Flags = cdlOFNHideReadOnly
  ' Set the folder where you want to start
  CommonDialog1.InitDir = "C:\"
  ' Set filters
  CommonDialog1.Filter = "All Files (*.*)|*.*|Text Files" & _
  "(*.txt)|*.txt|Batch Files (*.bat)|*.bat"
  ' Specify default filter
  CommonDialog1.FilterIndex = 2
  ' Display the Open dialog box
  CommonDialog1.ShowOpen
  ' Display name of selected file
  MsgBox CommonDialog1.FileName
  Exit Sub
 
ErrHandler:
  'User pressed the Cancel button
  Exit Sub

End Sub


Probably you will want to play with Flags property. Look here for help:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbcondisplayingopensaveasdialogboxes.asp
0
 

Author Comment

by:Aiysha
ID: 11794125
Thanx for all the comments.

Micheal_D and bobbit31: Thank you for the detailed code. I should have mentioned this earlier, I am trying to export values from msh grid in VB6.0 to excel spreadsheet. If you could send codelines that do such transfer it will be very helpful for me.

0
 
LVL 13

Expert Comment

by:Michael_D
ID: 11798283
Sorry about that but you are changing the question's topic.
Good practice is start the new post with your question so other experts can participate as well.
If you'll act like this I'm sure you'll get needed answer.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 22 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question