Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-04-02
7
Medium Priority
?
1,279 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 100 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 100 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

636 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