我目前正在处理执行以下操作的VBA代码:
1.将一张报纸从一张纸复制到另一张(同一张工作簿)
复制自动收报机的工作表应刷新并由bloomberg填充
该表格将导出为PDF
在第一张纸中没有更多代码时执行相同的处理。
我遇到了问题,因为我创建的代码似乎与Bloomberg无法正常工作。迭代效果很好,导出到PDF部分也是如此。然而,当循环进行时,Bloomberg没有足够的时间来刷新我想要导出的工作表。我最终用N / As中的四张中的三张而不是正确的数据。
这是我到目前为止所拥有的
Public Sub RefreshStaticLinks()
Call Worksheets("M").UsedRange.Select
Call Application.Run("RefreshCurrentSelection")
Call Application.OnTime(Now + TimeValue("00:01:00"), "M_PDF")
End Sub
Sub Mosaic_PDF()
Dim File_Path As String
Dim File_Name As String
Dim ReportTic As String
Dim Rng As Range, cl As Range
Set Rng = Worksheets("Set_up").Range("A2:A300")
With Worksheets("Mosaic")
For Each cl In Rng
If cl <> "" Then
Sheets("Mosaic").Range("G3") = cl
With Worksheets("Mosaic")
Call Application.Run("RefreshStaticLinks")
End With
File_Path = "N:\DATA\EQTY\EQFUND\SI\Projects\Standard Reporting\PDF Reports\Mosaic Fundamental Positioning\"
File_Name = "Fundamental Positioning Summary "
ReportTic = Format(ActiveWorkbook.Sheets("Mosaic").Range("G3").Text)
'Exports to pdf
With ActiveWorkbook
With Sheets(Array("Mosaic")).Select
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=File_Path & File_Name & ReportTic & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End With
End With
End If
Next cl
End With
End Sub