Common dialog

Common dialog

Anonymous
Not applicable
329 Views
1 Reply
Message 1 of 2

Common dialog

Anonymous
Not applicable
Hi all, I have a module that needs to get a filename, so I initiate a form with a common dialog. The CD starts fine, I get the filename, but I can't automatically close the form that the CD is on. What am I doing wrong? Here is what I am trying: Private Sub cd_gettemplate_Exit(ByVal Cancel As MSForms.ReturnBoolean) gettemplatefile.hide ' I thought this would close the form, but I was wrong. End Sub Private Sub UserForm_Initialize() cd_gettemplate.InitDir = templatedirectory cd_gettemplate.Filter = "TEM|*.TEM" cd_gettemplate.DialogTitle = "Select Template File" cd_gettemplate.ShowSave templatefilename = cd_gettemplate.FileName End Sub I have been learning VBA over the last week and would like to thank the following for their past contributions to the newsgroup which I have trawled for many other answers: (in alphabetical order) R. Robert Bell Laurie Comerford Frank Oquendo Lanny Schiele Joe Sutphin Tony Tanzillo and many others. Thanks Jon
0 Likes
330 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Hi Jon, You've embarrassed me by listing me with the knowledgable here. However, The approach I would take would be to put an OK command in the form and read the file name at that time. On the OK_Click event the code can include "me.hide" to hide the form, or if you wish the OK to initiate your computations, you could do them and end the program with "Unload me" -- Laurie Comerford CADApps www.cadapps.com.au "Jon" wrote in message news:415b400d_1@newsprd01... > Hi all, > > I have a module that needs to get a filename, so I initiate a form with a > common dialog. The CD starts fine, I get the filename, but I can't > automatically close the form that the CD is on. What am I doing wrong? > Here is what I am trying: > > Private Sub cd_gettemplate_Exit(ByVal Cancel As MSForms.ReturnBoolean) > gettemplatefile.hide ' I thought this would close the form, but I was > wrong. > End Sub > > Private Sub UserForm_Initialize() > cd_gettemplate.InitDir = templatedirectory > cd_gettemplate.Filter = "TEM|*.TEM" > cd_gettemplate.DialogTitle = "Select Template File" > cd_gettemplate.ShowSave > templatefilename = cd_gettemplate.FileName > End Sub > > I have been learning VBA over the last week and would like to thank the > following for their past contributions to the newsgroup which I have trawled > for many other answers: (in alphabetical order) > R. Robert Bell > Laurie Comerford > Frank Oquendo > Lanny Schiele > Joe Sutphin > Tony Tanzillo > and many others. > > Thanks > > Jon >
0 Likes