使用ssrs链接构buildexcel报告 – 如何传递在Excel表格中input的dynamicdate参数

我有excel报告使用ssrs报告链接 –

http:// Serverlink / ReportServer?%2fFinance%2fReportname&rs:Command = Render&FromDate = 01/31/2016&ToDate = 03/13/2016&rs:Format = Excel 。 当我在macros中使用它来运行button单击命令的报告时,这工作正常

Private Sub ViewReport_Click() Workbooks.Open Filename:= _ "http://Serverlink/ReportServer?%2fFinance%2fReportname&rs:Command=Render&FromDate=01/31/2016&ToDate=03/13/2016&rs:Format=Excel" ActiveSheet.Range("A8:I2000").Select Selection.Copy Application.DisplayAlerts = False ActiveWorkbook.Close SaveChanges:=False Windows(ThisWorkbook.Name).Activate Range("A8").Select ActiveSheet.Paste End Sub 

但我需要通过在Excel表格中input的dynamicdate到URL链接 – 在DTPicker。 我怎么能实现它?

Ecxelmacros捕获

您只需将电子表格中的date读入variables并格式化即可。 然后将这些variables与URL连接起来。

假设你的开始date在单元格“A1”中,而你的结束date在单元格“A2”中。

 Dim fromDate As String Dim toDate As String fromDate = Format(Range("a1").Value, "dd/mm/yyyy") toDate = Format(Range("a2").Value, "dd/mm/yyyy") Workbooks.Open Filename:= _ "http://Serverlink/ReportServer?%2fFinance%2fReportname&rs:Command=Render&FromDate=" & fromDate & "&ToDate=" & toDate & "&rs:Format=Excel"