Solved

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

Posted on 2004-04-02
7
1,264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

733 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