Home

Got Error 424 when running Macro

%3CLINGO-SUB%20id%3D%22lingo-sub-1170978%22%20slang%3D%22en-US%22%3EGot%20Error%20424%20when%20running%20Macro%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1170978%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20Excel%20with%20Macro%20which%20was%20developed%20in%20O365.%20It's%20running%20fine%20and%20without%20issue%20before.%20However%2C%20recently%20the%20Excel%20on%20server%20has%20been%20changed%20from%20O365%20to%20Excel%202016.%20Then%20I%20found%20the%20Macro%20will%20throw%20Error%20424%20when%20it%20is%20trying%20to%20close%20the%20objects.%20The%20code%20that%20highlighted%20in%20red%20is%20where%20I%20found%20it%20will%20throw%20error%20when%20I%20debug.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDim%20VBP%20As%20VBProject%2C%20oWin%20As%20VBIDE.Window%3CBR%20%2F%3EDim%20wbActive%20As%20Workbook%3CBR%20%2F%3EDim%20i%20As%20Integer%3CBR%20%2F%3E%3CBR%20%2F%3ESet%20VBP%20%3D%20WB.VBProject%3CBR%20%2F%3ESet%20wbActive%20%3D%20ActiveWorkbook%3C%2FP%3E%3CP%3E'%20Close%20any%20code%20windows%20To%20ensure%20we%20hit%20the%20right%20project%3CBR%20%2F%3EFor%20Each%20oWin%20In%20VBP.VBE.Windows%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CSTRONG%3EIf%20InStr(oWin.Caption%2C%20%22(%22)%20%26gt%3B%200%20Then%20oWin.Close%3C%2FSTRONG%3E%3C%2FFONT%3E%3CBR%20%2F%3ENext%20oWin%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20debug%20in%20O365%2C%20system%20shows%20the%20%22Object%20Browser%22%20in%20Caption.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22O365.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171010i3A70E2721A6C34CE%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22O365.jpg%22%20alt%3D%22O365.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20in%20Excel%202016%2C%20it%20is%20unable%20to%20define%20and%26nbsp%3B%3CFONT%20color%3D%22%23FF0000%22%3E%3CSTRONG%3EoWin.Caption%20%3C%2FSTRONG%3E%3CFONT%20color%3D%22%23000000%22%3Eis%3C%2FFONT%3E%3C%2FFONT%3E%20%3COBJECT%20required%3D%22%22%3E.%3C%2FOBJECT%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Excel2016.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171011i7D23748C6B81C7E8%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Excel2016.jpg%22%20alt%3D%22Excel2016.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ENow%2C%20I'm%20wondering%20if%20the%20object%20library%20is%20lost%20during%20the%20Excel%20version%20uninstall%20and%20changing%20process.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20help%20and%20advise.%20Thanks.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E2%80%83%E2%80%83%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1170978%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Occasional Visitor

I have a Excel with Macro which was developed in O365. It's running fine and without issue before. However, recently the Excel on server has been changed from O365 to Excel 2016. Then I found the Macro will throw Error 424 when it is trying to close the objects. The code that highlighted in red is where I found it will throw error when I debug.

 

Dim VBP As VBProject, oWin As VBIDE.Window
Dim wbActive As Workbook
Dim i As Integer

Set VBP = WB.VBProject
Set wbActive = ActiveWorkbook

' Close any code windows To ensure we hit the right project
For Each oWin In VBP.VBE.Windows
If InStr(oWin.Caption, "(") > 0 Then oWin.Close
Next oWin

 

When I debug in O365, system shows the "Object Browser" in Caption.

O365.jpg

 

But in Excel 2016, it is unable to define and oWin.Caption is <Object required>.

Excel2016.jpg

Now, I'm wondering if the object library is lost during the Excel version uninstall and changing process.

 

Please help and advise. Thanks.

 

  

Related Conversations
MSTeams Groups in outlook with macros disabled
ReadyorNot in Microsoft Teams on
0 Replies
Unknown Login Error
Alex_P3462 in Microsoft Teams on
0 Replies
Spelling Pop-Up Stuck on SharePoint List
aricornish in SharePoint on
0 Replies
Problem with OneDrive
esholder in OneDrive for Business on
5 Replies