Hey guys,
I'm currently working on a macro that automatically duplicates a study three times; in the end, I want to have four studies, with different names and a few changes in the pack/holding profile.
However, I'm stuck in a particular question: is it possible to tell the macro that the study name is variable? Because here's what I'd like the macro to do: from a study named "study_fpw01", the macro would automatically create three new studies named "study_fpw02", "study_fpw03" and "study_fpw04".
I've looked into the API Reference and found a few commands that I think it could help me:
I tried to work with this last command, but it can only get the first study name or the next study name. Is there something more specific for this case?
Thank you for taking the time to read this.
Best regards
Hi,
as you have the first study, I think this could be a method:
Set Project = Synergy.Project() Project.DuplicateStudyByName2 "study_fpw01", True Project.RenameItemByName "study_fpw01 (copy)", "Study", "study_fpw02" Project.DuplicateStudyByName2 "study_fpw01", True Project.RenameItemByName "study_fpw01 (copy)", "Study", "study_fpw03"
Hope this helps.
Regards,
Berndt
Hello Berndt Nordh,
thank you very much for your help.
I tried to run your code but it wasn't able to do what I expected. That's because this code does not recognize the name of the first study as a variable. Is there some kind of command that can do this? Because I would like it to work for any study that I might work with in the future.
Best Regards,
Heitor
Hello Heitor,
a couple of options:
You can open the first study by name:
Set Project = Synergy.Project() Project.OpenItemByName "study_fpw01", "Study"
Or open the first study in project, and assuming it holds your first study study_fpw01 :
Set Project=Synergy.Project() StudyName =Project.GetFirstStudyName() Project.OpenItemByName StudyName, "Study"
Or, open a study manually (or by script) and get the active study name to use:
Set StudyDoc = Synergy.StudyDoc() StudyActive = StudyDoc.StudyName '** this is with .sdy StudyActiveName = left(StudyDoc.StudyName, len(StudyDoc.StudyName)-4) '** this is without .sdy
Hope you find that something of above will resolve your script issue.
Regards,
Berndt