2003 vs 2007 Excel code

bcurrey

Board Regular
Joined
Aug 11, 2011
Messages
110
Office Version
  1. 365
Platform
  1. MacOS
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!

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
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How do you know this?? The works now that I removed this section and a couple other pieces.

Is there a "decoder" or something available that would tell me it's not compatible? I have 3-4 more macros I need to do the same thing to.

I appreciate your help!!!
 
Upvote 0
SImply open your file in the oldest version that it needs to work under, then got to the VBA editor and select Debug, compile.
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,629
Members
452,933
Latest member
patv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top