How can you change the current open location directory?

Hi, does anyone have any idea how I can change the folder corel takes me to when I goto file/save as (or press ctrl+shift+s) through vba?

I'm using a SQL database to find a job folder from an ID number. We organize our jobs by Year/Customer/Jobname so it can be a time consuming to find the folder you're looking for when there is 1000's of them to search through. Right now you key in the 6 digit ID number, it finds the financial year, customer and job name then takes you straight to it. So far everything is working but one critical feature...

I'm opening the folder using CorelScriptTools.GetFileBox to access the artwork files inside (various formats). After this i want to save the new document (.cdr) in that exact folder from which I opened the artwork, the only problem is takes me to the last folder i saved a CDR file in from previous job i worked on, making the macro a waste of time for starting jobs and only useful for finding existing ones.

I can't find any information on doing this through corel but I assume there is some registry or something I could edit on the fly through VBA? Any pointers or suggestions would be very much appreciated as this macro will speed up our workflow significantly.

I don't want to import the file onto a automatically saved document as the format of artwork varies a lot, there is often multiple files and you may want to save multiple files within that folder for the same job.

Thanks

Parents
  • Howard,

    You can pass a folder to GetFileBox. Here are two example:

    Sub TestFileSelection()
        Dim FileName As String
        
        'Set the folder to open
        FileName = CorelScriptTools.GetFileBox(Folder:="C:\Temp\")
        
        'Set a filter for only cdr file and default folder
        'FileName = CorelScriptTools.GetFileBox("CDR - CorelDRAW (*.cdr)|*.cdr", "Please select a CorelDRAW file to open", 1, "", "cdr", "C:\Temp\")
    
        If FileName <> "" Then
            MsgBox "File selected was: " & FileName
        End If
    End Sub
    

    If you wanted it to remember the last folder you selected you could use the SaveSetting to write the folder to the registery and then read in the saved setting. 

    Happy coding, 

    -Shelby

Reply Children