Hi All,
I have a bug about call a macro in excel that need your help.
I wrote a macro setColor() to set background color and set value to sheet1 of excel file A, end then at excel file B, I called this macro of file A, But there a bug.
in excel 2003 my code only can set value and can't not set background color for file A, althought this macro run OK when called at file A.
in the case, I open both file A and file B by excel 2007 , it run OK.
So do My code have any problem? and How to My macro can run at both excel 2003 and 2007 even excel 2010?
this is may code:
file A(calMacroOtherFile.xls):
Public Sub setColor()
With Workbooks(Application.ThisWorkbook.Name).Worksheets("Sheet1")
.Range(.Cells(3, 5), .Cells(6, 5)).Interior.ColorIndex = 3
.Cells(3, 4).Interior.ColorIndex = 15
.Cells(3, 4).Value = "ckfjfio"
MsgBox "Workbook Name: " & workBookName
End With
End Sub
file B:
Private Sub CommandButton1_Click()
On Error GoTo ErrorCode
Application.Run ("'calMacroOtherFile.xls'!setColor()")
Exit Sub
ErrorCode:
MsgBox "Error discription: " & Err.Description
End Sub
Thank in advance