Solved

code for browse to specific location.

Posted on 2004-08-12
4
144 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
  • 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now