I'm working on a macro to make it faster for saving a file in my file naming system/structure.
It's still a work in progress but I'm getting hung up on the syntax of how to compile the values of the user form to the file name.
Here's the file name I'm trying to create.
12345_PTR_36x24_050922
I'm getting stuck on how to write the code to bring all that information together.
SaveAsForm.txtAccount.Value_SaveAsForm.ComboBox1.Value_SaveAsForm.txtW.ValuexSaveAsForm.txtH.Value_SaveAsForm.CurrentDate.Value
Here's a video explanation.Thanks!
Private Sub SaveLocation_Click() Const sFolderPath As String = "D:\Sync\Sales Team\" 'Set your folder here Dim sFileName As String 'The name of our file 'Open file save as dialog, you can change this to *.* to see all files sFileName = CorelScriptTools.GetFileBox("CorelDRAW Files (*.cdr)|*.cdr", "Save As", 1, SaveAsForm.txtAccount.Value, , sFolderPath) 'A quick check to make sure a file name was entered If sFileName = " " Then Exit Sub End If 'Save the file ActiveDocument.SaveAs sFileName End Sub
I don't have time to write a more detailed response at the moment, but consider that what you have to supply there is a String.
You need to "put together" the complete String for the filename by combining other Strings.
Do some web searching about concatenating strings in VBA. You will probably find yourself using the "&" operator.
You can look back at this thread - Multiple images export - and see an example in your code there:
path = sfolder & "\" & groupname & "_" & i & ".png"
There is some "implicit type conversion" going on there. Even though i is a Long, it automatically gets converted to a string when the concatenation is performed.
Thank you for remembering my own post! I got it working now!