Solved

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

Posted on 2004-04-02
7
1,260 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

758 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

22 Experts available now in Live!

Get 1:1 Help Now