![]() |
|
#1
|
|||
|
|||
![]()
As part of a macro, I have the code below to open documents, and it works O.K.
However, I understand this code is originally meant to filter and select several files, and so it includes a “For Next” loop. But I don’t need such a loop, as I open just one file each time I run the macro. The trouble is the relevant line inside the loop, by itself, hasn't got the correct syntax; it must be altered in some way that I don’t know. Any help with just that, please, or suggestions for an alternative method? Thanks a lot. Note. I first sent this query to the general Word forum, which was probably not the proper one; I hope it’s not against the rules to shift it to this one. ACA Code:
Sub Macro1() ' ' Macro1 Macro Dim fd As FileDialog Set fd = Application.FileDialog(msoFileDialogFilePicker) Dim vrtSelectedItem As Variant fd.Filters.Clear If fd.Show = True Then For Each vrtSelectedItem In fd.SelectedItems Documents.Open FileName:=vrtSelectedItem ‘How must this line be altered so that it'll work by itself, without the loop?. Next vrtSelectedItem End If End Sub Last edited by ACA; 08-07-2011 at 12:49 PM. Reason: I intended to mark this as 'Solved', but I cannot find how to do that |
#2
|
|||
|
|||
![]()
Sub Macro1()
Dim fd As FileDialog Set fd = Application.FileDialog(msoFileDialogFilePicker) fd.Filters.Clear fd.AllowMultiSelect = False If fd.Show = True Then Documents.Open FileName:=fd.SelectedItems(1) End If End Sub |
#3
|
|||
|
|||
![]()
Thank you very much, gmaxey. This is it; exactly what I wanted.
I'm marking this thread 'Solved' and add to your reputation ACA |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
msadiqrajani | Word | 2 | 05-27-2011 08:11 PM |
![]() |
cookiegal | Word | 7 | 04-04-2011 12:37 AM |
Opening zip file attachments in MS Outlook | shankar | Outlook | 0 | 12-07-2010 09:15 PM |
problem opening ms word 2007 file | shanchita rahman | Word | 0 | 11-17-2010 08:43 AM |
Opening MSO-2000 file in MSO-2003 | w77 | Word | 0 | 04-21-2009 03:30 AM |