Hello,I have active document DOCUMENT_0000000001.cdrI need macro to save active document as DOCUMENT_0000000002.cdrEach run of macro SAVE_AS must save active document with name increased with 1 of active document.
Each activation of the macro should save the active document with the name of the active document incremented by 1.
So, if active document name is DOCUMENT_0000000199.cdr, SAVE_AS macro activation must save active document as DOCUMENT_0000000200.cdr
Greetings!
Whenever you are solving a programming problem, the first step is to break down the problem into smaller problems. For example, in your case:
First, we need to analyze the file name to obtain its numbering.lets break this too:use substring to get numeric part of string string - Substring in VBA - Stack Overflowconverting string to intHow to Convert String to Integer in VBA (With Examples) - Statology Second, how do we increment this numbering? Next, how do we generate the new name?CREATE 100 FILES - CorelDRAW and Corel DESIGNER API - Developer Area - CorelDRAW Community Finally, we save the document.Document.SaveAs method - Developer Area - CorelDRAW Community
Hello,Thank You very much, but not work!I hope to get a more practical working answer. Looking for one as my routines are quite slow. I think there are always better ways.Greetings!BGНадявам се да получа по-практичен работещ отговор. Търся такъв, тъй като моите процедури са доста бавни. Мисля си, че винаги има и по-добри начини.
The algorithm I use isFor x = 1 to 100SaveAs ActiveDocument.FullPath & "DOCUMENT_" & Leading zeros & x & ".cdr"Now I will explain in detail.I expect something betterGreetings!
These three command lines may prove useful in solving the problem.MsgBox ActiveDocument.FullFileNameMsgBox ActiveDocument.FileNameMsgBox ActiveDocument.FilePath
In my case returned strings are:G:\COREL_MACROS_FROM_INTERNET\CREATE_100_FILES\MASTER_DOCUMENT.cdrMASTER_DOCUMENT.cdrG:\COREL_MACROS_FROM_INTERNET\CREATE_100_FILES\
I would recomment using the SaveAsCopy.
Sub SaveManyCopies() Dim x As Integer For x = 1 To 10 ActiveDocument.SaveAsCopy ActiveDocument.FilePath & "DOCUMENT_" & Format(x, "0000000###") & ".cdr" Next x End Sub
Happy coding,
-Shelby