I have a report which contains 2 tabs Lets say TabA and TabB and I am using a macro to duplicate those tabs for each site.currently when I duplicate those tabs they are inserted as TabA(1), TabA(2), TabA(3), TabB(1), TabB(2), TabB(3) on my report.
Is is possible for me to insert those tabs in a specific position ? because I want to place them like tabA(1), TabB(1), TabA(2), TabB(2), TabA(3), TabB(3)
Any help will be appreciated
Here’s an out of the box idea. Instead of using the duplicate function, how about adding blank reports and applying a template instead? That way you control the order. The following code duplicates Report1 and Report2 in a controlled order:
Sub DuplicateTabsInOrder()
Dim Rpt As Report
Dim TemplateDir As String
'create templates
TemplateDir = Application.GetInstallDirectory(boTemplateDirectory)
ThisDocument.Reports("Report1").Activate
Call ThisDocument.SaveAs(TemplateDir & "\Report1.ret")
ThisDocument.Reports("Report2").Activate
Call ThisDocument.SaveAs(TemplateDir & "\Report2.ret")
'add blank reports, rename, and apply template
Set Rpt = ThisDocument.Reports.Add
Rpt.Name = "Report1 (1)"
Call Rpt.ApplyTemplate("Report1")
Set Rpt = ThisDocument.Reports.Add
Rpt.Name = "Report2 (1)"
Call Rpt.ApplyTemplate("Report2")
End Sub
Depending on the complexity of your reports, the possible limitation is that using this “apply template” method may not duplicate the report exactly.