Sub GenerateReport()
On Error GoTo CONNECTERROR
If (testconnection() = True) Then
If Not (Sheets("Price History").Range("b5").Value = "") Then
Dim n As Date
Dim p As Date
n = Date
p = n - 182
Sheets("Price History").ChartObjects("Chart 9").Activate
ActiveChart.ChartTitle.Characters.Text = "6 Month History for " & Sheets("Price History").Range("d5").Value
Windows("Thingy V6.xls").Activate
With Sheets("Hiddn - Specific History Data").Range("A1").QueryTable
.Connection = _
"TEXT;http://ichart.finance.yahoo.com/table.csv?s=" & Sheets("Price History").Range("c5").Value & ".L&a=" & (Format(p, "mm") - 1) & "&b=" & Format(p, "dd") & "&c=" & Format(p, "yyyy") & "&d=" & (Format(n, "mm") - 1) & "&e=" & Format(n, "dd") & "&f=" & Format(n, "yyyy") & "&g=d&ignore=.csv"
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
.Refresh BackgroundQuery:=False
End With
End If
Else
Call MsgBox("You must be connected to the internet to view a company history", vbOKOnly, "Company History")
End If
Exit Sub
CONNECTERROR:
MsgBox "Data Unavailable at the moment, or not at all for this company", vbOKOnly, "Company History"
Exit Sub
End Sub