![]() |
#1
|
|||
|
|||
![]()
I have looked for info to do this, but couldn't find any specific examples:
I want to create a form to list the files located in a folder. The user can then select a name from the list, which opens that file and the macro will proceed to do its work with that file. Could someone spare some time to show me some code examples? If I can get the basics, then I can modify to suit. Thanks. |
#2
|
|||
|
|||
![]()
First a file array function...
Code:
Function FileArray(Path As String) Dim Name As String, Counter As Integer, Files() As String Name = Dir(Path, vbReadOnly) Counter = 0 Do While Name <> "" If Name <> "." And Name <> ".." Then ReDim Preserve Files(Counter) Files(Counter) = Name Counter = Counter + 1 End If Name = Dir Loop FileArray = Files() End Function Code:
Private Sub UserForm_Initialize() Dim Files As Variant, NewDocument As Variant, Folder As String Folder = "C:\Path\" ' ENTER PATH HERE Files = FileArray(Folder) For Each NewDocument In Files FileList.AddItem NewDocument 'ASSUMING U HAVE A LISTBOX FileList IN THE FORM Next End Sub Private Sub OK_Click() Dim Folder As String Folder = "C:\Path\" ' ENTER PATH HERE OpenDocument (Folder + FileList.Value) Unload Me End Sub |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Retrieve names list of constants in a given enumeration | zlatev | CorelDRAW/Corel DESIGNER VBA | 5 | 09-02-2009 20:12 |
Where does COrelPhotopaint 12 keeps its Globalmacros file? | cyrilgupta | Corel Photo-Paint VBA | 1 | 08-11-2004 15:02 |
Browse for Folder | shelbym | CorelDRAW/Corel DESIGNER VBA | 2 | 12-04-2004 17:13 |