pramod kumar
May 10th, 2001, 07:03 AM
I want to save file and I want to give the default file name for that.
I set filename property, but it show some error
plz, help me
this is my code.
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Public Function ShowSave(Parenthwnd As Long, Filter As String, strSaveFileName As String, InitialDir As String, Title As String, Optional DifExtension As String) As String
Dim OFName As OPENFILENAME
If IsMissing(DifExtension) = False Then
OFName.nFileExtension = 0
End If
OFName.lStructSize = Len(OFName)
OFName.hwndOwner = Parenthwnd
OFName.hInstance = App.hInstance
OFName.lpstrFilter = Filter
OFName.lpstrFile = strSaveFileName 'Space$(254)
OFName.nMaxFile = 255
OFName.lpstrFileTitle = Space$(254)
OFName.nMaxFileTitle = 255
OFName.lpstrInitialDir = InitialDir
OFName.lpstrTitle = Title
OFName.flags = 0
If GetSaveFileName(OFName) Then
ShowSave = TrimNull(Trim$(OFName.lpstrFile))
Else
ShowSave = ""
End If
End Function
Private Sub cmdSave_Click()
Dim fl As Long
Dim MyString As String, MyFile As String
fl = FreeFile
MyFile = ShowSave(Me.hWnd, "All files (*.*)" & Chr(0) & "*.*" & Chr(0) & "Log Files (*.log)" & Chr(0) & "*.log" & Chr(0), "MyTxt.txt", "c:\", "Save")
If MyFile <> "" Then
Open MyFile & MySaveName For Output As #fl
Print #fl, Me.Text1.Text
End If
Close #fl
End Sub
I set filename property, but it show some error
plz, help me
this is my code.
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Public Function ShowSave(Parenthwnd As Long, Filter As String, strSaveFileName As String, InitialDir As String, Title As String, Optional DifExtension As String) As String
Dim OFName As OPENFILENAME
If IsMissing(DifExtension) = False Then
OFName.nFileExtension = 0
End If
OFName.lStructSize = Len(OFName)
OFName.hwndOwner = Parenthwnd
OFName.hInstance = App.hInstance
OFName.lpstrFilter = Filter
OFName.lpstrFile = strSaveFileName 'Space$(254)
OFName.nMaxFile = 255
OFName.lpstrFileTitle = Space$(254)
OFName.nMaxFileTitle = 255
OFName.lpstrInitialDir = InitialDir
OFName.lpstrTitle = Title
OFName.flags = 0
If GetSaveFileName(OFName) Then
ShowSave = TrimNull(Trim$(OFName.lpstrFile))
Else
ShowSave = ""
End If
End Function
Private Sub cmdSave_Click()
Dim fl As Long
Dim MyString As String, MyFile As String
fl = FreeFile
MyFile = ShowSave(Me.hWnd, "All files (*.*)" & Chr(0) & "*.*" & Chr(0) & "Log Files (*.log)" & Chr(0) & "*.log" & Chr(0), "MyTxt.txt", "c:\", "Save")
If MyFile <> "" Then
Open MyFile & MySaveName For Output As #fl
Print #fl, Me.Text1.Text
End If
Close #fl
End Sub