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
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
Thanks Shelby, though its not exactly what I am looking for. Maybe I miss understand how SaveSetting can be used but I thought that was just specific macro settings and not Corel's native settings. What I really need is for Corel to change the location Corel takes me to when i press Ctrl + O.
I thought I was onto something when I changed the 'open' registry entry with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Private Function SvRegEd(ByVal FinalFolder As String) FinalFolder = Replace(FinalFolder, "\", "\\") Dim RegO As Object Set RegO = CreateObject("WScript.Shell") Dim myRegKey As String myRegKey = "HKEY_CURRENT_USER\Software\Corel\CorelDRAW\17.0\Draw\Application Preferences\Open\OpenDialogSettings" Dim RegKeyRead As String RegKeyRead = RegO.RegRead(myRegKey) Dim SplitStr() As String SplitStr() = split(RegKeyRead, Chr(34)) SplitStr(5) = FinalFolder SplitStr(33) = FinalFolder RegKeyRead = Join(SplitStr, Chr(34)) RegO.RegWrite myRegKey, RegKeyRead End Function
Changes this:
To this:
However this doesn't seem to work, as it still takes me to the last used folder i manually navigated to. I really thought it would work :|
Am I editing the wrong registry file, taking the wrong approach or is this just not achievable?
Since if you open a document from a specific directory and this registry key is not modified, but the Save As dialog will open in that new location, this should mean that corel keeps this information somewhere even if not in registry. I mean after the value has been read from registry. The new value is saved in registry when corel closes but it must be a way to find that intermediary place where corel keeps it until closing.
Even if we do not know where it is (yet)...