Solved

code for browse to specific location.

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA saving file message display 5 72
MsgBox 2 59
Put text in a picture ASP.NET C# 2 60
Sending a email via excel using vba 6 97
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

808 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