Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Two File Dialogs

For some reason, the code below displays the file dialog twice in
a row. It shows the dialog, the user selects files, it shows the
dialog again, the user selects files, and then it writes the second
set of selections to a worksheet.

I do not understand why it displays the dialog twice. I would
appreciate any pointers.

Thanks, Alan

Sub SelectDocuments()
Const OutputFileCaption As String = _
"Please select one or more Word documents"
Dim dialog As FileDialog
Dim FileFilter As FileDialogFilters
Dim NumFiles As Integer, i As Integer
Set WBmain = GetActiveWB
Set ConfigWS = CreateConfigWS(WBmain)
ConfigWS.Activate
ConfigWS.Visible = xlSheetVisible
Set dialog = Application.FileDialog(msoFileDialogFilePicker)
With dialog
Set FileFilter = .Filters
FileFilter.Clear
FileFilter.Add "Word documents", "*.doc, *.docx"
.AllowMultiSelect = True
If .Show = 0 Then Exit Sub
NumFiles = .SelectedItems.Count
If .SelectedItems.Count 0 Then
For i = 1 To NumFiles
ConfigWS.Cells(i + 1, 2).Value = .SelectedItems.Item(i)
Next i
End If
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Two File Dialogs

This is only one of th emacros in your workbook. there is probably another
macro that is causing the dialog to open twice. I would step through the
code to find where the dialog is opening twice or post more of the code.

Tto A break point click on line below and then press F9

If .Show = 0 Then Exit Sub

This is the line that displays the dialog. Then press F5 to continue. If
the dialog opens before reaching this line or after then there is another
place in the code that opens the dialog. If it reaches this statemnt twice
then something is causing this routine to run twice.

You can use F8 to step through the code after reaching a break point. Or
set more than one break point using F8 to find the trouble.

"Alan" wrote:

For some reason, the code below displays the file dialog twice in
a row. It shows the dialog, the user selects files, it shows the
dialog again, the user selects files, and then it writes the second
set of selections to a worksheet.

I do not understand why it displays the dialog twice. I would
appreciate any pointers.

Thanks, Alan

Sub SelectDocuments()
Const OutputFileCaption As String = _
"Please select one or more Word documents"
Dim dialog As FileDialog
Dim FileFilter As FileDialogFilters
Dim NumFiles As Integer, i As Integer
Set WBmain = GetActiveWB
Set ConfigWS = CreateConfigWS(WBmain)
ConfigWS.Activate
ConfigWS.Visible = xlSheetVisible
Set dialog = Application.FileDialog(msoFileDialogFilePicker)
With dialog
Set FileFilter = .Filters
FileFilter.Clear
FileFilter.Add "Word documents", "*.doc, *.docx"
.AllowMultiSelect = True
If .Show = 0 Then Exit Sub
NumFiles = .SelectedItems.Count
If .SelectedItems.Count 0 Then
For i = 1 To NumFiles
ConfigWS.Cells(i + 1, 2).Value = .SelectedItems.Item(i)
Next i
End If
End With
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Two File Dialogs

The problem turned out to be software gremlins. When I opened the
file tonight, the subroutine I posted was no longer there. I
recreated it exactly as before, and it works.

Go figure.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
dialogs OlieH Excel Programming 0 August 1st 07 10:42 PM
Dialogs OlieH Excel Programming 3 July 14th 07 06:58 PM
dialogs Damien Excel Programming 2 March 7th 07 09:36 PM
dialogs Damien Excel Programming 0 March 7th 07 05:35 AM
Dialogs nc Excel Discussion (Misc queries) 1 March 23rd 05 02:17 PM


All times are GMT +1. The time now is 03:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"