OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 28-03-2005, 10:15
RVogel
Guest
 
Posts: n/a
Default List names of files located in a folder

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.
Reply With Quote
  #2  
Old 31-03-2005, 16:14
Mark
Guest
 
Posts: n/a
Default List Files

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
Then the form...

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
That should work...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
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


All times are GMT -5. The time now is 01:28.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com