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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CommonDialog InitDir

Status
Not open for further replies.

hansu

Programmer
Mar 12, 2002
89
I use the CommonDialog control (cdlMain) for the user to save html files. I want to prevent the user from changing directories. It seems to me that setting the flag cdlOFNNoChangeDir doesn't have any influence.
Code:
strDir = "d:\hutlogs\confirmations"
    With cdlMain
        .CancelError = True
        .DefaultExt = "html"
        .FileName = txtFields(0) & " " & Date
        .Filter = "HTML Datei (*.html)|*.html"
        .Flags = cdlOFNHideReadOnly + cdlOFNPathMustExist + cdlOFNOverwritePrompt+cdlOFNNoChangeDir
        .InitDir = "d:\test"
        .ShowSave
    End With

Thanks for your help.
 
If you have a fixed directory why use the Common Dialog control? Simply create a form that prompts them for a filename, then save to your directory.

Matt
 
Thanks for your reply MattSTech. The only reason is the functionality of the CommonDialog, like checking whether the file already exists.
 
Use the File system object to check to see if the file exists. It is referenced by:

Microsoft Scripting runtime

Example:

Dim FSO as New FileSystemObject

If FSO.FileExists ("C:\myHTML.html") then
msgbox"it exists"
'more code to do your save
end if

This is just an example but I don't believe the Common Dialog is what you need in this case.

Hope this helps

Matt
 
To see if a file exists, just use Dir

If Len(Dir ("c:\mydir\myfile.htm") > 0 Then
' File exists

________________________________________________________________
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?'
 
MattSTech and johnwm
Yes I agree with you, it's better in this case to use a customized form for the user to save the file and then check whether the file already exists. Thank you very much for your suggestions how check that.
That helped me a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top