当尝试打开ftp文件时,它指出Microsoft excel由于多种可能的原因无法访问该文件。但是,我似乎无法弄清楚是什么原因导致它无法正常工作。我的想法已经用光了。
它在
处中断Workbooks.Open Filename:="ftp://ftp.cmegroup.com/pub/settle/nymex_future.csv"
此VBA以前可以使用,但不能在Office 2016上使用。
Sub GetData()
'
' CreateUploadFiles Macro
' Gets ICE and CME data, updates calculations and refreshes pivot tables
'
'
Sheets("Price Calc").Select
Range("C13").Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Copy
Range("C1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("ICE Gas.xls").Activate
Columns("A:K").Select
Selection.Copy
Windows("Market Price Upload Sheet.xlsm").Activate
Sheets("ICE Gas").Select
Columns("A:A").Select
ActiveSheet.Paste
ActiveSheet.Calculate
Windows("ICE Gas.xls").Activate
ActiveWindow.Close
Windows("ICE Power.xls").Activate
Columns("A:K").Select
Selection.Copy
Windows("Market Price Upload Sheet.xlsm").Activate
Sheets("ICE Power").Select
Columns("A:A").Select
ActiveSheet.Paste
ActiveSheet.Calculate
Windows("ICE Power.xls").Activate
ActiveWindow.Close
Workbooks.Open Filename:="ftp://ftp.cmegroup.com/pub/settle/nymex_future.csv"
ActiveWindow.Visible = False
Windows("nymex_future.csv").Visible = True
ActiveWindow.WindowState = xlNormal
Application.DisplayAlerts = False
ActiveWindow.WindowState = xlNormal
ActiveWorkbook.SaveAs Filename:= _
"v:\RAM MRA-SOX\Pricing Data\nymex_future.csv", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
Workbooks.Open Filename:="ftp://ftp.cmegroup.com/pub/settle/nymex_option.csv"
ActiveWindow.Visible = False
Windows("nymex_option.csv").Visible = True
ActiveWindow.WindowState = xlNormal
ActiveWindow.WindowState = xlNormal
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"v:\RAM MRA-SOX\Pricing Data\nymex_option.csv", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
Windows("nymex_future.csv").Activate
Columns("A:T").Select
Selection.Copy
Windows("Market Price Upload Sheet.xlsm").Activate
Sheets("CME Futures").Select
Columns("A:A").Select
ActiveSheet.Paste
ActiveSheet.Calculate
Windows("nymex_future.csv").Activate
ActiveWindow.Close
Windows("nymex_option.csv").Activate
Columns("A:V").Select
Selection.Copy
Windows("Market Price Upload Sheet.xlsm").Activate
Sheets("CME Option").Select
Columns("A:A").Select
ActiveSheet.Paste
ActiveSheet.Calculate
Windows("nymex_option.csv").Activate
ActiveWindow.Close
Sheets("ICE Gas Pivot").Select
Range("A6").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
Sheets("ICE Power Pivot").Select
Range("A6").Select
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
Sheets("Option Pivot").Select
Range("A6").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
Range("F6").Select
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
Sheets("CME Pivot").Select
ActiveSheet.PivotTables("PivotTable4").PivotCache.Refresh
Sheets("Price Calc").Select
ActiveSheet.Calculate
Sheets("Curve").Select
ActiveSheet.Calculate
Sheets("Market Prices").Select
ActiveSheet.Calculate
Sheets("Vol Calc").Select
ActiveSheet.Calculate
Sheets("WGES_Gas").Select
ActiveSheet.Calculate
Sheets("WGES_Power").Select
ActiveSheet.Calculate
Sheets("WGES_Basis").Select
ActiveSheet.Calculate
Sheets("WGES_Discount").Select
ActiveSheet.Calculate
Sheets("Instructions").Select
End Sub