Does Excel Automation support VB's MsgBox?

When I compile a Codeunit contained xlApplication.MsgBox (’…’) where xlApplication is an Excel Automation datatype, an error message pop up: You have specified an unknown variable. MsgBox It seems MsgBox is not usable in Navision. If this is true, how can I pop up a message box in Excel after I open an Excel file?

Simply use Navision equivalent to msgbox which is the MESSAGE command in C/AL. If XL_Open_Success Then MESSAGE(‘Excel File %1 has been generated’, FileName); ###### tarek_demiati@ureach.com

Hi, I have been looking through some Excel Automation controls in the Navision Symbol Menu and haven’t found any reference to the MsgBox… in fact looks like that this feature is not supported by Excel Automation and it’s not a Navision problem. Somehow it’s understandable because you do not need to open Excel in a new window (runs totally in background), so there is no way to open a MsgBox from VBA. I guess Tareks suggestion is an easy way to solve this. Saludos Nils

I agree with the suggestion to just use the message box in C/SIDE, but just for fun I wanted to show how you could possibly do this using Excel. { Declarations Required (versions may differ): XL As ‘Microsoft Excel 9.0 Object Library’.Application Workbook As ‘Microsoft Excel 9.0 Object Library’.Workbook VBProject As ‘Microsoft Visual Basic for Applications Extensibility 5.3’.VBProject VBComponents As ‘Microsoft Visual Basic for Applications Extensibility 5.3’.VBComponents VBComponent As ‘Microsoft Visual Basic for Applications Extensibility 5.3’.VBComponent CodeModule As ‘Microsoft Visual Basic for Applications Extensibility 5.3’.CodeModule CodeModule.AddFromString(‘Sub MyMsgBox(Msg):MsgBox Msg:End Sub’); } CREATE(XL); Workbook := XL.Workbooks.Add; VBProject := Workbook.VBProject; VBComponents := VBProject.VBComponents; VBComponent := VBComponents.Add(1); CodeModule := VBComponent.CodeModule; CodeModule.AddFromString(‘Sub MyMsgBox(Msg):MsgBox Msg:End Sub’); XL.Run(‘MyMsgBox’,‘Hello World’); Make sure to use this method if your productivity is measured by “Lines of Code.” :slight_smile: Jim Hollcraft NCSD, NCSP, MCP, MST aka Skater drilldot.com - Unauthorized Navision News

Thanks, guys. What I am doing is updating a comprehensive sales analysis report by using Excel Automation. What is updating monthly is few reserved lines on each of ten sheets according to which month. Excel must be visible once it is opened because the Excel file requires a password to open. My idea is poping up a MsgBox in Excel to let user knowing the report is done because the user will not go back to Navision Financials to see a message while Excel is visible at the front of screen.