Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-07-2011, 02:22 AM
ACA ACA is offline Opening a file with FileDialogFilePicker Windows 7 Opening a file with FileDialogFilePicker Office 2007
Advanced Beginner
Opening a file with FileDialogFilePicker
 
Join Date: Aug 2010
Posts: 31
ACA is on a distinguished road
Default Opening a file with FileDialogFilePicker

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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a file with FileDialogFilePicker Issue when opening word file msadiqrajani Word 2 05-27-2011 08:11 PM
Opening a file with FileDialogFilePicker MS Word - There was an error opening the file 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

Other Forums: Access Forums

All times are GMT -7. The time now is 08:08 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft