|
-
Mar 30th, 2003, 07:11 PM
#1
Thread Starter
New Member
Form button property Solved
I have a button on a form that opens a save as dialog box. Once the file is saved the file name is set to the text property in a text box on the form but the form closes as soon as the file is saved. I want the form to remain open after the file is saved. Is there a button property or code that will keep the form open?
Last edited by feistdj; Mar 31st, 2003 at 11:39 PM.
-
Mar 30th, 2003, 08:46 PM
#2
Frenzied Member
Maybe you cold be a little more specific, let us see the code you are using to do all this and we can probably find the problem.
-
Mar 30th, 2003, 11:45 PM
#3
Thread Starter
New Member
Button Code
I just cut and pasted this from my code so I'll explain. The button opens a template Excel file and changes its extension when it is saved. This program had to be coded without the use of OCX or ActiveX controls (for system compatbility reasons) that is why I didn't use the common dialog box method.
vbcode
Private Sub project_new_Click()
ERH_PushStack_TSB ("frmdlgFiles.project_new_Click")
Dim NewBook As Workbook
Dim fName As String
Set NewBook = Application.Workbooks.Add("C:\defproj.cs2")
fName = Application.GetSaveAsFilename
If Right(fName, 4) <> ".cs2" Then
fName = fName & ".cs2"
End If
NewBook.SaveAs FileName:=fName
project_edit.Text = fName
ThisWorkbook.Saved = False
End
/vbcode
-
Mar 31st, 2003, 01:26 AM
#4
The thing I see is the command "END" which of course will and the whole code not only the Sub! an "End Sub " would be better!
If you're trying to post code using the Vbcode-tags surround them with [ ], that helps.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Mar 31st, 2003, 04:10 AM
#5
Frenzied Member
Yea it looks like End might be doing it eh... Try this...
VB Code:
Private Sub project_new()
ERH_PushStack_TSB ("frmdlgFiles.project_new_Click")
Dim NewBook As Workbook
Dim fName As String
Set NewBook = Application.Workbooks.Add("C:\defproj.cs2")
fName = Application.GetSaveAsFilename
If Right(fName, 4) <> ".cs2" Then
fName = fName & ".cs2"
End If
NewBook.SaveAs Filename:=fName
project_edit.Text = fName
ThisWorkbook.Saved = False
End Sub
I am amazed your code worked without "End Sub" at the bottom.
-
Mar 31st, 2003, 11:38 PM
#6
Thread Starter
New Member
End Sub
Yes, a stupid oversight. I did have End Sub in the code but it was after the unnecessary End statement. The final code with error handler is:
VB Code:
Private Sub project_new_Click()
ERH_PushStack_TSB ("frmdlgFiles.project_new_Click")
Dim NewBook As Workbook
Dim fName As String
Set NewBook = Application.Workbooks.Add("C:\defproj.cs2")
fName = Application.GetSaveAsFilename
If Right(fName, 4) <> ".cs2" Then
fName = fName & ".cs2"
End If
NewBook.SaveAs FileName:=fName
project_edit.Text = fName
ThisWorkbook.Saved = False
Proc_exit:
ERH_PopStack_TSB
Exit Sub
Proc_err:
ERH_Handler_TSB
Resume Proc_exit
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|