Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CommonDialog ShowSave Problem

Status
Not open for further replies.

debeebop

Programmer
Dec 14, 2005
6
0
0
EG
Hello everyone,

How do I get the File Name field in the Save As window to have a default name? Like the one in MS Word for example...


I also want to disable the Save button next to the File Name field whenever the user enters a Null name...

Any help?

Thanks
 
Do you mean "CommonDialog1.Filename = "MyName.txt"


[gray]Experience is something you don't get until just after you need it.[/gray]
 
No, that's not what I was looking for.
I'm trying to get my code to save some information in a text file, using the Common Dialog.
Everything worked fine.

But when the save as... window pops up on the screen I want the Field name to have a default value instead of Null.

This is a piece of my code:

Dim file as string

CommonDialog1.ShowSave
file = CommonDialog.FileName
If file <> "" Then
Open file for Output as #1
Write #1, "BlaBlaBla"
Close #1,
End if

 
Hi and welcome to Tek-Tips. Read through faq222-2244 to see how to get the best from this forum. It will give guidelines on how to ask the right questions to get you the answers you want.

I guess from your reply that you didn't try the code that Error7 showed you, or didn't look it up in VBHelp to see how it is used. You are also using a reserved word ('file') as a variable name, which is not recommended. It's also good practise to use the FreeFile function to get a file handle.

Try this:(just a snippet, NOT production code!)
Code:
Dim strFile as string
Dim intHandle As Integer
intHandle = FreeFile
CommonDialog1.InitDir = "c:\"
CommonDialog1.FileName = "Fred.txt"
CommonDialog1.ShowSave
strFile = CommonDialog1.FileName
If strFile <> "" Then
 Open strFile for Output as #intHandle
 Write #intHandle, "BlaBlaBla"
 Close #intHandle
End if

To get started next time, try using VBHelp or MSDN on line to get the simple syntax questions sorted, as it's generally not expected that you will be offered full code answers

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top