This question is a bit of a Hail Mary throw...I have a query at my company that runs and save the raw data as file q1.xls then a macro (below) runs and exports 2 cells as a png file and then saves the excel file as r.xls.
Oddly enough, all users have Excel 2007 (I used to build this) installed on their computers, but our system still runs off 2003. I've tested this code repeatedly on my local computer and it works fine. When I attach it to the query running off 2003, it errors out because it doesn't like something in this VBA code.
Does anyone see something that might not be 2003 compatible? Thanks!
Oddly enough, all users have Excel 2007 (I used to build this) installed on their computers, but our system still runs off 2003. I've tested this code repeatedly on my local computer and it works fine. When I attach it to the query running off 2003, it errors out because it doesn't like something in this VBA code.
Does anyone see something that might not be 2003 compatible? Thanks!
Code:
Workbooks.Open Filename:="D:\pbs\temp\q1.xls"
Sheets.Add After:=Sheets(Sheets.Count)
Cells.Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G6").Select
ActiveCell.FormulaR1C1 = "=COUNT('Query NO 666'!C[-6])"
Selection.Font.Size = 18
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Font.Bold = True
Selection.Font.Size = 26
Sheets("Query NO 666").Select
ActiveSheet.Range("$A$1:$I$85").AutoFilter Field:=2, Criteria1:="IO"
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.ClearContents
ActiveSheet.Range("$A$1:$I$85").AutoFilter Field:=2
ActiveWindow.SmallScroll ToRight:=4
ActiveWindow.SmallScroll Down:=-12
ActiveSheet.Range("$A$1:$I$85").AutoFilter Field:=8, Criteria1:= _
"No longer spoolable"
Rows("3:169").Select
Range("E3").Activate
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.ClearContents
ActiveSheet.Range("$A$1:$I$85").AutoFilter Field:=8
Range("A3").Select
Sheets("Query NO 666").Select
Sheets("Sheet1").Select
Range("A1").Select
' save a range from Excel as a picture
Dim rng As Excel.Range
Dim cht As Excel.ChartObject
Const strPath As String = "D:\data\fci_queries\Real Time Stats\Dashboard\"
Application.ScreenUpdating = False
Set rng = Excel.Range("G6:G7").CurrentRegion
rng.CopyPicture xlScreen, xlPicture
Set cht = ActiveSheet.ChartObjects.Add(0, 0, rng.Width + 0.01, rng.Height + 0.01)
cht.Chart.Paste
cht.Chart.Export strPath & "latealert_nm.png"
cht.Delete
ExitProc:
Application.ScreenUpdating = True
Set cht = Nothing
Set rng = Nothing
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="D:\PBS\temp\r.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Application.Quit
End Sub