How do I integrate the VB6 CommonDialog control so that the user can enter their own file name and override a pre-determined file name?

I have a couple of VB6 subs that use a button click and fso to .Writeline some settings to a .txt type of file that can then use .Readline to restore the values.

Question: How do I integrate the CommonDialog control into this so that the user can enter their own file name and override the pre-determined file name? I just can't seem to get this to work...many thanks.

Private Sub mnu_SaveStatus_Click()
     SaveSettings App.Path & "\settings.set"
End Sub

Private Sub SaveSettings(ByVal FileName As String)

Set strm = fso.CreateTextFile(FileName, True)
     With strm

     .WriteLine Text1.Text
     .WriteLine Text2.Text
     .WriteLine Text3.Text

     End With

End Sub
Who is Participating?
GrahamSkanConnect With a Mentor RetiredCommented:
You just use the control's FileName property.
Private Sub Command1_Click()
    SaveSettings Me.CommonDialog1.FileName
End Sub

Open in new window

Deepu SreedharBI Software EngineerCommented:
Same like GrahamSkan said.
Place CommonDialogControl on your form and just call it on your Private Sub mnu_SaveStatus_Click()

 Like below:

Private Sub mnu_SaveStatus_Click()
    SaveSettings CommonDialogName.FileName
End Sub
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.