Solved

how to make a default file name in a save file dialog for users

Posted on 2004-04-02
7
1,263 Views
Last Modified: 2013-12-25
hi everybody...I wanna know how to make a default file name in a save file dialog for users
and I want to open a text file in VB ...how can I do that....?

Thanks


0
Comment
Question by:starstarhk
  • 2
  • 2
7 Comments
 
LVL 27

Accepted Solution

by:
jjafferr earned 25 total points
ID: 10746115
Hi starstarhk,
This is the second part of your question:

           Open "C:\DeleteMe.txt" For Input As #1    ' Open file for input.
            Do While Not EOF(1)    ' Loop until end of file.

            Line Input #1, TextLine    ' Read line into variable.
' do something here
           Loop
           Close #1            'Close the input file and move to the next file


Hope this helps

jaffer
0
 

Author Comment

by:starstarhk
ID: 10746139
but I am using FileSystemObject, the object name is SaveDialog..

SaveDialog.CancelError = True
    On Error GoTo ErrHandler
       SaveDialog.DialogTitle = "Save your File!"
    SaveDialog.Filter = "Text File(*.txt)|*.txt|"
    SaveDialog.ShowSave
    fileName = SaveDialog.fileName
       If Not FSO.FileExists(fileName) Then ' if not exist→Create
       Set TS = FSO.CreateTextFile(fileName)
    Else  ' if exist→Open
       Set TS = FSO.CreateTextFile(fileName, ForWriting)
   End If



And how to open a text file...is it ShellExecuteEX(....,.....)?
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 10746272
I don't know about FileSystemObject and SaveDialog, I have a different way to do it, its through a module. If you wish, I can provided to you.

Now for your second part,
Do you want to open a txt file and read its content from VB,
(I already gave you the answer for this option)
OR
Open a txt file in notepade?
Dim myProcess as New Process()
myProcess.StartInfo.FileName = "Notepad.exe"
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
myProcess.Start()

jaffer
0
 
LVL 5

Assisted Solution

by:crazycomputers
crazycomputers earned 25 total points
ID: 10746527
According to MSDN:

"In the CommonDialog control, you can set the FileName property before opening a dialog box to set an initial filename."

SaveDialog.FileName = "default file.txt"   ' for example
0
 
LVL 5

Expert Comment

by:crazycomputers
ID: 11044249
Agreed.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 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