|
Question : CommonDialog Question
|
|
I'm using a CommonDialog control to open a dialog box and save a file. This is the code I'm using:
Dim cc As New CommonDialog Dim strtxt As String Dim strfltr As String Dim strname As String
strfltr = "Microsoft Excel Workbook (*.xls), *.XLS, xls" strtxt = "*.xls" strFilePrefix = "test"
With cc .InitDir = "d:\downloads" .Filter = strfltr .FilterIndex = 1 .FileName = strFilePrefix & ".xls" .DefaultExt = strtxt .DialogTitle = "This is a test" .ShowSave End With
When I run it I get an error on the .DefaultExt which says "Invalid property value". If I comment that line out I get to .ShowSave which opens up the dialog box to save the file.
The problem is that there is no name in the File Name field. When I type in a name I get an error which says, "Method ShowSave of object ICommondialog failed.
So I would appreciate any help with this problem. Thanks.
|
|
Answer : CommonDialog Question
|
|
I'm assuming that you did not add a Common Dialog control on your form.
Add a common dialog control onto your form (it won't show up on the form so placement isn't important). Change its name to ComDlg. You'll find it listed under the More Controls button on the Toolbox.
Also make the following code changes:
' Remove the NEW keyword from your Dim statement Dim cc As CommonDialog
' Add this line before the "With cc" statement. Set cc = Me!ComDlg.Object
Let me know your results (both with the DefaultExt statement and without it).
|
|
|