2003 macro to 2007

davehill01

New Member
Joined
Jun 22, 2012
Messages
10
Hi all

I have a 2003 macro which I inherited from someone else. In theory I believe it should run in 2007.

But when I run it I get the following error message.

Run-time error '445'
Object doesn't support this action


Here's the macro.

Can anyone help me to get it working please.

Thanks in advance

Dave



Option Explicit

Public Enum ExcelVersion
Excel2000
Excel2002
Excel2003
Excel2007
Excel2010
Unknown
End Enum


Function CheckExcelVersion() As ExcelVersion
'Check the Excel Version
Select Case Application.Version
Case "9.0"
CheckExcelVersion = Excel2000
Case "10.0"
CheckExcelVersion = Excel2002
Case "11.0"
CheckExcelVersion = Excel2003
Case "12.0"
CheckExcelVersion = Excel2007
Case "14.0"
CheckExcelVersion = Excel2010
Case Else
CheckExcelVersion = Unknown
End Select
End Function


Public Sub Run_Spreadsheet_Compare(Optional Session As String = "")
Dim fMain As New frmMain
fMain.OpenSession = Session
fMain.Show vbModal

'frmMain.Show vbModal
End Sub


Sub Run_SyncScroll()
Dim ApplicationVersion As ExcelVersion
ApplicationVersion = CheckExcelVersion()

'Feature added in Excel 2003
If ApplicationVersion >= Excel2003 Then
Dim Window1 As Window
Dim Window2 As Window

If Windows.Count < 2 Then
MsgBox "Need two Windows open to synchronise scrolling", vbExclamation
Exit Sub
End If

'Disable side by side
'Windows.BreakSideBySide
CallByName Windows, "BreakSideBySide", VbMethod

'Set the two windows to make side by side
Set Window1 = ActiveWindow
If Windows(1).Caption = Window1.Caption Then
Set Window2 = Windows(2)
Else
Set Window2 = Windows(1)
End If

'Normalise 2nd Window
Window2.Zoom = Window1.Zoom
Window2.Activate
Window2.ScrollRow = 1
Window2.ScrollColumn = 1

'Normalise 1st window
Window1.Activate
Window1.ScrollRow = 1
Window1.ScrollColumn = 1

'Set side by side
'Windows.CompareSideBySideWith Window2.Caption
CallByName Windows, "CompareSideBySideWith", VbMethod, Window2.Caption

'Windows.Arrange ArrangeStyle:=xlVertical
CallByName Windows, "Arrange", VbMethod, -4166 '(xlVertical)
'CallByName Windows, "Arrange", VbMethod, -4128 '(xlHorizontal)

'Open edit form
frmSyncScroll.Show vbModeless
Else
MsgBox "Only supported in Excel 2003 onwards.", vbExclamation
End If
End Sub


Public Function Min(Value1 As Integer, Value2 As Integer) As Integer
'Return the smallest of two numbers
If Value1 < Value2 Then
Min = Value1
Else
Min = Value2
End If
End Function
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,216,118
Messages
6,128,939
Members
449,480
Latest member
yesitisasport

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