[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

code for browse to specific location.

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
Aiysha
Asked:
Aiysha
  • 2
2 Solutions
 
bobbit31Commented:
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
 
Michael_DCommented:
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
 
AiyshaAuthor Commented:
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
 
Michael_DCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now