First off, thanks to everyone that has helped this newbie programmer get this far.
I can't seem to figure out to get my program to do a "Save As." The program runs fine, even pops up the ShowSave dialog box, but the file never actually saves.
Bascially, the user opens a file, it gets edited and written into test.txt. I then want the user to be able to specify a file name and have test.txt written to that file, then test.txt deleted.
Here's what I have thus far:
Private Sub Command1_Click()
CommonDialog1.DialogTitle = "Choose File to Open"
CommonDialog1.Filter = "ACL File (*.acl)|*.acl"
CommonDialog1.DefaultExt = "acl"
CommonDialog1.FilterIndex = 1
CommonDialog1.CancelError = True
CommonDialog1.ShowOpen
Dim first, last, Space As String
Dim OutRecord(80), NewRecord As String
Space = " "
Open CommonDialog1.filename For Input As #1
Open App.Path & "\test.txt" For Output Shared As #2
' Read in record reformat and write out
' Remove col 1 len 8 left just
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, first ' Read data
'Debug.Print first ' Print data to Debug window.
'
'OutRecord
i = 0
For j = 9 To 80
i = i + 1
OutRecord(i) = Mid(first, j, 1)
Next
' perpare output record
i = 0
NewRecord = Space
Do While i < 80
NewRecord = NewRecord & OutRecord(i)
i = i + 1
Loop
'Write #2,
Print #2, NewRecord
Loop
Close #1 ' Close file.
CommonDialog1.DialogTitle = "Save File"
CommonDialog1.Filter = "CL File (*.cl)|*.cl"
CommonDialog1.DefaultExt = "cl"
CommonDialog1.FilterIndex = 1
CommonDialog1.Flags = cdlOFNHideReadOnly + cdlOFNOverwritePrompt _
+ cdlOFNPathMustExist
CommonDialog1.CancelError = True
CommonDialog1.ShowSave
Close #2
Kill App.Path & "\test.txt"
End Sub
Jody
I can't seem to figure out to get my program to do a "Save As." The program runs fine, even pops up the ShowSave dialog box, but the file never actually saves.
Bascially, the user opens a file, it gets edited and written into test.txt. I then want the user to be able to specify a file name and have test.txt written to that file, then test.txt deleted.
Here's what I have thus far:
Private Sub Command1_Click()
CommonDialog1.DialogTitle = "Choose File to Open"
CommonDialog1.Filter = "ACL File (*.acl)|*.acl"
CommonDialog1.DefaultExt = "acl"
CommonDialog1.FilterIndex = 1
CommonDialog1.CancelError = True
CommonDialog1.ShowOpen
Dim first, last, Space As String
Dim OutRecord(80), NewRecord As String
Space = " "
Open CommonDialog1.filename For Input As #1
Open App.Path & "\test.txt" For Output Shared As #2
' Read in record reformat and write out
' Remove col 1 len 8 left just
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, first ' Read data
'Debug.Print first ' Print data to Debug window.
'
'OutRecord
i = 0
For j = 9 To 80
i = i + 1
OutRecord(i) = Mid(first, j, 1)
Next
' perpare output record
i = 0
NewRecord = Space
Do While i < 80
NewRecord = NewRecord & OutRecord(i)
i = i + 1
Loop
'Write #2,
Print #2, NewRecord
Loop
Close #1 ' Close file.
CommonDialog1.DialogTitle = "Save File"
CommonDialog1.Filter = "CL File (*.cl)|*.cl"
CommonDialog1.DefaultExt = "cl"
CommonDialog1.FilterIndex = 1
CommonDialog1.Flags = cdlOFNHideReadOnly + cdlOFNOverwritePrompt _
+ cdlOFNPathMustExist
CommonDialog1.CancelError = True
CommonDialog1.ShowSave
Close #2
Kill App.Path & "\test.txt"
End Sub
Jody