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

Insert Save Button in UserForm Window Bar

Status
Not open for further replies.

bdmangum

Technical User
Dec 6, 2006
171
US
Howdy,

I was recently contemplating dfiferent methods of allowing a user to save the workbook while running a user form. I thought it might be neat to add a save button next to the close form button (the X in the top right corner). VBA has a built in option of adding a Help button next to the close button, but does anyone know of a method to add a custom button instead of a help button?

If anyone knows a method to accomplish this task, please speak up. I browsed the forum and couldn't find anything similar to this. I assume there has to be a way to accomplish this. If I was clear, let me know and I'll rephrase the question.

BD
 
I'm bumping this thread back to the top in order to hopefully receive a response. *BUMP*
 

I don't think you can (easily) add a button to the UserForm's Window Bar, but what you CAN do is prompt the User to Save changes when he/she exits the Form either by Unload Me in an Exit command button, ot by clicking an 'X' in upper right corner of the UserForm by:
Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

If vbYes = MsgBox("Do you want to Save changes?", vbYesNo) Then
    [green]'... Save[/green]
End If

End Sub

Have fun.

---- Andy
 
The way I have the code setup is the user is always using a form. When they attempt to close the form, the code blocks the attempt.

I was simply looking to see if anyone knew of a way to add a button to the user form window bar. I am unaware of a method of doing that. I thought it might add a cool little feature to the macro.

I guess I'll just have to insert a command button which the user can click to save the file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top