I Wrote some vba code to do everything , but the porblem is it exports into 60 excel files I want one excel file with 60 tabs. Can any one help me.
code..
Private Sub Document_AfterRefresh()
Dim dopDoc As Document
Dim mydopRptAs Report
Dim FilterVar As DocumentVariable
Dim FilterChoices As Variant
Dim i, intNumChoices As Integer
Dim strNextValue As String
Set dopDoc = ThisDocument
Set mydopRpt= ActiveReport
' Put your variable (or query object) here
Set FilterVar = dopDoc.DocumentVariables("Cos Cd"
' find out how many resort values there are
intNumChoices = UBound(FilterVar.Values(boUniqueValues))
' collect the number of choices in a variant variable
FilterChoices = FilterVar.Values(boUniqueValues)
For i = 1 To intNumChoices
' Get the variable value
strNextValue = myFilterChoices(i)
' Duplicate Report
mydopRpt.AddComplexFilter FilterVar, "=<Cos Cd>=" & """" & strNextValue & """"
mydopRpt.Duplicate.Name = "COS " & strNextValue
' recompute the report
mydopRpt.ForceCompute
mydopRpt.ExportAsText ("v:\BO TEMP\COS " & strNextValue & ".xls"
Next i
End Sub
code..
Private Sub Document_AfterRefresh()
Dim dopDoc As Document
Dim mydopRptAs Report
Dim FilterVar As DocumentVariable
Dim FilterChoices As Variant
Dim i, intNumChoices As Integer
Dim strNextValue As String
Set dopDoc = ThisDocument
Set mydopRpt= ActiveReport
' Put your variable (or query object) here
Set FilterVar = dopDoc.DocumentVariables("Cos Cd"
' find out how many resort values there are
intNumChoices = UBound(FilterVar.Values(boUniqueValues))
' collect the number of choices in a variant variable
FilterChoices = FilterVar.Values(boUniqueValues)
For i = 1 To intNumChoices
' Get the variable value
strNextValue = myFilterChoices(i)
' Duplicate Report
mydopRpt.AddComplexFilter FilterVar, "=<Cos Cd>=" & """" & strNextValue & """"
mydopRpt.Duplicate.Name = "COS " & strNextValue
' recompute the report
mydopRpt.ForceCompute
mydopRpt.ExportAsText ("v:\BO TEMP\COS " & strNextValue & ".xls"
Next i
End Sub