Solved

code for browse to specific location.

Posted on 2004-08-12
4
149 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 250 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 250 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

707 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