Prev: Microsoft Dynamics NAV Case Studies
Next: Freelance/Independant Dynamics Nav (Navision) Consultant looking for new projects worldwide
From: PSM on 28 Oct 2009 04:59 I'm trying to copy a sheet from one book to another by a codeunit in Navision. If you did it in Excel you'd use: - Sheets("sheet name").Select - Sheets("sheet name").Copy After := WorkBooks("book name").Sheets(sheet number) In Navision, you can only use - Sheets.Copy('After); Do anyone know how can I do it? Thanks.
From: Spider on 3 Nov 2009 02:26
Here is a sample CU ===================== OBJECT Codeunit 99099 TestExcel { OBJECT-PROPERTIES { Date=03-11-09; Time=[ 6:23:40 PM]; Modified=Yes; Version List=killme; } PROPERTIES { OnRun=BEGIN OpenBook('C:\temp\killme\tsheet2.xlsx','tsheet2'); XlApp.Workbooks.Add; XlWrkBk2 := XlApp.ActiveWorkbook; XlWrkBk2.Worksheets.Add; XlWrkSht2 := XlWrkBk2.Worksheets.Item(1); XlWrkSht.Copy(XlWrkSht2); XlWrkBk2.SaveAs('C:\temp\killme\tsheet1.xlsx'); ClearApp; END; } CODE { VAR XlApp(a)1101223012 : Automation "{00020813-0000-0000-C000-000000000046} 1.2:{00024500-0000-0000-C000-000000000046}:Unknown Automation Server.Application"; XlWrkBk(a)1101223011 : Automation "{00020813-0000-0000-C000-000000000046} 1.2:{00020819-0000-0000-C000-000000000046}:Unknown Automation Server.Workbook"; XlWrkBk2(a)1101223040 : Automation "{00020813-0000-0000-C000-000000000046} 1.2:{00020819-0000-0000-C000-000000000046}:Unknown Automation Server.Workbook"; XlWrkSht(a)1101223010 : Automation "{00020813-0000-0000-C000-000000000046} 1.2:{00020820-0000-0000-C000-000000000046}:Unknown Automation Server.Worksheet"; XlWrkSht2(a)1101223041 : Automation "{00020813-0000-0000-C000-000000000046} 1.2:{00020820-0000-0000-C000-000000000046}:Unknown Automation Server.Worksheet"; XlWrkshts(a)1101223009 : Automation "{00020813-0000-0000-C000-000000000046} 1.2:{000208D8-0000-0000-C000-000000000046}:Unknown Automation Server._Worksheet"; Text000(a)1101223039 : TextConst 'ENU=Excel not found.;ENA=Excel not found.;ENZ=Excel not found.'; Text001(a)1101223038 : TextConst 'ENU=You must enter a file name.;ENA=You must enter a file name.;ENZ=You must enter a file name.'; Text002(a)1101223037 : TextConst 'ENU=You must enter an Excel worksheet name.;ENA=You must enter an Excel worksheet name.;ENZ=You must enter an Excel worksheet name.'; Text003(a)1101223036 : TextConst 'ENU=The file %1 does not exist.;ENA=The file %1 does not exist.;ENZ=The file %1 does not exist.'; Text004(a)1101223035 : TextConst 'ENU=The Excel worksheet %1 does not exist.;ENA=The Excel worksheet %1 does not exist.;ENZ=The Excel worksheet %1 does not exist.'; PROCEDURE OpenBook@2(FileName(a)1000 : Text[250];SheetName(a)1001 : Text[250]); VAR i(a)1002 : Integer; EndOfLoop(a)1003 : Integer; Found(a)1004 : Boolean; BEGIN IF FileName = '' THEN ERROR(Text001); IF SheetName = '' THEN ERROR(Text002); IF NOT ISSERVICETIER THEN IF NOT EXISTS(FileName) THEN ERROR(Text003,FileName); IF NOT CREATE(XlApp,TRUE,TRUE) THEN ERROR(Text000); XlApp.Workbooks.Open(FileName); XlWrkBk := XlApp.ActiveWorkbook; i := 1; EndOfLoop := XlWrkBk.Worksheets.Count; WHILE (i <= EndOfLoop) AND (NOT Found) DO BEGIN XlWrkshts := XlWrkBk.Worksheets.Item(i); IF SheetName = XlWrkshts.Name THEN Found := TRUE; i := i + 1; END; IF Found THEN XlWrkSht := XlWrkBk.Worksheets.Item(SheetName) ELSE BEGIN XlWrkBk.Close(FALSE); XlApp.Quit; CLEAR(XlApp); ERROR(Text004,SheetName); END; END; PROCEDURE ClearApp(a)1101223000(); BEGIN XlWrkBk.Close(FALSE); XlWrkBk2.Close(FALSE); XlApp.Quit; CLEAR(XlApp); END; EVENT XlWrkSht(a)1101223010::SelectionChange(a)1543(Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range"); BEGIN END; EVENT XlWrkSht(a)1101223010::BeforeDoubleClick(a)1537(Target(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range";VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkSht(a)1101223010::BeforeRightClick(a)1534(Target(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range";VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkSht(a)1101223010::Activate(a)304(); BEGIN END; EVENT XlWrkSht(a)1101223010::Deactivate(a)1530(); BEGIN END; EVENT XlWrkSht(a)1101223010::Calculate(a)279(); BEGIN END; EVENT XlWrkSht(a)1101223010::Change(a)1545(Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range"); BEGIN END; EVENT XlWrkSht(a)1101223010::FollowHyperlink(a)1470(Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00024431-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Hyperlink"); BEGIN END; EVENT XlWrkSht(a)1101223010::PivotTableUpdate(a)2156(Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020872-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.PivotTable"); BEGIN END; EVENT XlWrkBk(a)1101223011::Open(a)1923(); BEGIN END; EVENT XlWrkBk(a)1101223011::Activate(a)304(); BEGIN END; EVENT XlWrkBk(a)1101223011::Deactivate(a)1530(); BEGIN END; EVENT XlWrkBk(a)1101223011::BeforeClose(a)1546(VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk(a)1101223011::BeforeSave(a)1547(SaveAsUI(a)1101223001 : Boolean;VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk(a)1101223011::BeforePrint(a)1549(VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk(a)1101223011::NewSheet(a)1550(Sh(a)1101223000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN END; EVENT XlWrkBk(a)1101223011::AddinInstall(a)1552(); BEGIN END; EVENT XlWrkBk(a)1101223011::AddinUninstall(a)1553(); BEGIN END; EVENT XlWrkBk(a)1101223011::WindowResize(a)1554(Wn(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020893-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Window"); BEGIN END; EVENT XlWrkBk(a)1101223011::WindowActivate(a)1556(Wn(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020893-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Window"); BEGIN END; EVENT XlWrkBk(a)1101223011::WindowDeactivate(a)1557(Wn(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020893-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Window"); BEGIN END; EVENT XlWrkBk(a)1101223011::SheetSelectionChange(a)1558(Sh(a)1101223001 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range"); BEGIN END; EVENT XlWrkBk(a)1101223011::SheetBeforeDoubleClick(a)1559(Sh(a)1101223002 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range";VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk(a)1101223011::SheetBeforeRightClick(a)1560(Sh(a)1101223002 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range";VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk(a)1101223011::SheetActivate(a)1561(Sh(a)1101223000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN END; EVENT XlWrkBk(a)1101223011::SheetDeactivate(a)1562(Sh(a)1101223000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN END; EVENT XlWrkBk(a)1101223011::SheetCalculate(a)1563(Sh(a)1101223000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN END; EVENT XlWrkBk(a)1101223011::SheetChange(a)1564(Sh(a)1101223001 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range"); BEGIN END; EVENT XlWrkBk(a)1101223011::SheetFollowHyperlink(a)1854(Sh(a)1101223001 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00024431-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Hyperlink"); BEGIN END; EVENT XlWrkBk(a)1101223011::SheetPivotTableUpdate(a)2157(Sh(a)1101223001 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020872-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.PivotTable"); BEGIN END; EVENT XlWrkBk(a)1101223011::PivotTableCloseConnection(a)2158(Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020872-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.PivotTable"); BEGIN END; EVENT XlWrkBk(a)1101223011::PivotTableOpenConnection(a)2159(Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020872-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.PivotTable"); BEGIN END; EVENT XlWrkBk(a)1101223011::Sync(a)2266(SyncEventType(a)1101223000 : Integer); BEGIN END; EVENT XlWrkBk(a)1101223011::BeforeXmlImport(a)2283(Map(a)1101223003 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{0002447B-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.XmlMap";Url(a)1101223002 : Text[1024];IsRefresh(a)1101223001 : Boolean;VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk(a)1101223011::AfterXmlImport(a)2285(Map(a)1101223002 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{0002447B-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.XmlMap";IsRefresh(a)1101223001 : Boolean;Result(a)1101223000 : Integer); BEGIN END; EVENT XlWrkBk(a)1101223011::BeforeXmlExport(a)2287(Map(a)1101223002 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{0002447B-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.XmlMap";Url(a)1101223001 : Text[1024];VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk(a)1101223011::AfterXmlExport(a)2288(Map(a)1101223002 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{0002447B-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.XmlMap";Url(a)1101223001 : Text[1024];Result(a)1101223000 : Integer); BEGIN END; EVENT XlWrkBk(a)1101223011::RowsetComplete(a)2610(Description(a)1101223002 : Text[1024];Sheet(a)1101223001 : Text[1024];Success(a)1101223000 : Boolean); BEGIN END; EVENT XlApp(a)1101223012::NewWorkbook(a)1565(Wb(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook"); BEGIN END; EVENT XlApp(a)1101223012::SheetSelectionChange(a)1558(Sh(a)1101223001 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range"); BEGIN END; EVENT XlApp(a)1101223012::SheetBeforeDoubleClick(a)1559(Sh(a)1101223002 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range";VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlApp(a)1101223012::SheetBeforeRightClick(a)1560(Sh(a)1101223002 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range";VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlApp(a)1101223012::SheetActivate(a)1561(Sh(a)1101223000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN END; EVENT XlApp(a)1101223012::SheetDeactivate(a)1562(Sh(a)1101223000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN END; EVENT XlApp(a)1101223012::SheetCalculate(a)1563(Sh(a)1101223000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN END; EVENT XlApp(a)1101223012::SheetChange(a)1564(Sh(a)1101223001 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range"); BEGIN END; EVENT XlApp(a)1101223012::WorkbookOpen(a)1567(Wb(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook"); BEGIN END; EVENT XlApp(a)1101223012::WorkbookActivate(a)1568(Wb(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook"); BEGIN END; EVENT XlApp(a)1101223012::WorkbookDeactivate(a)1569(Wb(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook"); BEGIN END; EVENT XlApp(a)1101223012::WorkbookBeforeClose(a)1570(Wb(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlApp(a)1101223012::WorkbookBeforeSave(a)1571(Wb(a)1101223002 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";SaveAsUI(a)1101223001 : Boolean;VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlApp(a)1101223012::WorkbookBeforePrint(a)1572(Wb(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlApp(a)1101223012::WorkbookNewSheet(a)1573(Wb(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";Sh(a)1101223000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN END; EVENT XlApp(a)1101223012::WorkbookAddinInstall(a)1574(Wb(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook"); BEGIN END; EVENT XlApp(a)1101223012::WorkbookAddinUninstall(a)1575(Wb(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook"); BEGIN END; EVENT XlApp(a)1101223012::WindowResize(a)1554(Wb(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";Wn(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020893-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Window"); BEGIN END; EVENT XlApp(a)1101223012::WindowActivate(a)1556(Wb(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";Wn(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020893-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Window"); BEGIN END; EVENT XlApp(a)1101223012::WindowDeactivate(a)1557(Wb(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";Wn(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020893-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Window"); BEGIN END; EVENT XlApp(a)1101223012::SheetFollowHyperlink(a)1854(Sh(a)1101223001 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00024431-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Hyperlink"); BEGIN END; EVENT XlApp(a)1101223012::SheetPivotTableUpdate(a)2157(Sh(a)1101223001 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020872-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.PivotTable"); BEGIN END; EVENT XlApp(a)1101223012::WorkbookPivotTableCloseConnection(a)2160(Wb(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020872-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.PivotTable"); BEGIN END; EVENT XlApp(a)1101223012::WorkbookPivotTableOpenConnection(a)2161(Wb(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020872-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.PivotTable"); BEGIN END; EVENT XlApp(a)1101223012::WorkbookSync(a)2289(Wb(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";SyncEventType(a)1101223000 : Integer); BEGIN END; EVENT XlApp(a)1101223012::WorkbookBeforeXmlImport(a)2290(Wb(a)1101223004 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";Map(a)1101223003 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{0002447B-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.XmlMap";Url(a)1101223002 : Text[1024];IsRefresh(a)1101223001 : Boolean;VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlApp(a)1101223012::WorkbookAfterXmlImport(a)2291(Wb(a)1101223003 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";Map(a)1101223002 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{0002447B-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.XmlMap";IsRefresh(a)1101223001 : Boolean;Result(a)1101223000 : Integer); BEGIN END; EVENT XlApp(a)1101223012::WorkbookBeforeXmlExport(a)2292(Wb(a)1101223003 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";Map(a)1101223002 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{0002447B-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.XmlMap";Url(a)1101223001 : Text[1024];VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlApp(a)1101223012::WorkbookAfterXmlExport(a)2293(Wb(a)1101223003 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";Map(a)1101223002 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{0002447B-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.XmlMap";Url(a)1101223001 : Text[1024];Result(a)1101223000 : Integer); BEGIN END; EVENT XlApp(a)1101223012::WorkbookRowsetComplete(a)2611(Wb(a)1101223003 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020819-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Workbook";Description(a)1101223002 : Text[1024];Sheet(a)1101223001 : Text[1024];Success(a)1101223000 : Boolean); BEGIN END; EVENT XlApp(a)1101223012::AfterCalculate(a)2612(); BEGIN END; EVENT XlWrkBk2(a)1101223040::Open(a)1923(); BEGIN END; EVENT XlWrkBk2(a)1101223040::Activate(a)304(); BEGIN END; EVENT XlWrkBk2(a)1101223040::Deactivate(a)1530(); BEGIN END; EVENT XlWrkBk2(a)1101223040::BeforeClose(a)1546(VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk2(a)1101223040::BeforeSave(a)1547(SaveAsUI(a)1101223001 : Boolean;VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk2(a)1101223040::BeforePrint(a)1549(VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk2(a)1101223040::NewSheet(a)1550(Sh(a)1101223000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN END; EVENT XlWrkBk2(a)1101223040::AddinInstall(a)1552(); BEGIN END; EVENT XlWrkBk2(a)1101223040::AddinUninstall(a)1553(); BEGIN END; EVENT XlWrkBk2(a)1101223040::WindowResize(a)1554(Wn(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020893-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Window"); BEGIN END; EVENT XlWrkBk2(a)1101223040::WindowActivate(a)1556(Wn(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020893-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Window"); BEGIN END; EVENT XlWrkBk2(a)1101223040::WindowDeactivate(a)1557(Wn(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020893-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Window"); BEGIN END; EVENT XlWrkBk2(a)1101223040::SheetSelectionChange(a)1558(Sh(a)1101223001 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range"); BEGIN END; EVENT XlWrkBk2(a)1101223040::SheetBeforeDoubleClick(a)1559(Sh(a)1101223002 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range";VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk2(a)1101223040::SheetBeforeRightClick(a)1560(Sh(a)1101223002 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range";VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk2(a)1101223040::SheetActivate(a)1561(Sh(a)1101223000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN END; EVENT XlWrkBk2(a)1101223040::SheetDeactivate(a)1562(Sh(a)1101223000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN END; EVENT XlWrkBk2(a)1101223040::SheetCalculate(a)1563(Sh(a)1101223000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN END; EVENT XlWrkBk2(a)1101223040::SheetChange(a)1564(Sh(a)1101223001 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range"); BEGIN END; EVENT XlWrkBk2(a)1101223040::SheetFollowHyperlink(a)1854(Sh(a)1101223001 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00024431-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Hyperlink"); BEGIN END; EVENT XlWrkBk2(a)1101223040::SheetPivotTableUpdate(a)2157(Sh(a)1101223001 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH";Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020872-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.PivotTable"); BEGIN END; EVENT XlWrkBk2(a)1101223040::PivotTableCloseConnection(a)2158(Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020872-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.PivotTable"); BEGIN END; EVENT XlWrkBk2(a)1101223040::PivotTableOpenConnection(a)2159(Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020872-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.PivotTable"); BEGIN END; EVENT XlWrkBk2(a)1101223040::Sync(a)2266(SyncEventType(a)1101223000 : Integer); BEGIN END; EVENT XlWrkBk2(a)1101223040::BeforeXmlImport(a)2283(Map(a)1101223003 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{0002447B-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.XmlMap";Url(a)1101223002 : Text[1024];IsRefresh(a)1101223001 : Boolean;VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk2(a)1101223040::AfterXmlImport(a)2285(Map(a)1101223002 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{0002447B-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.XmlMap";IsRefresh(a)1101223001 : Boolean;Result(a)1101223000 : Integer); BEGIN END; EVENT XlWrkBk2(a)1101223040::BeforeXmlExport(a)2287(Map(a)1101223002 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{0002447B-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.XmlMap";Url(a)1101223001 : Text[1024];VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkBk2(a)1101223040::AfterXmlExport(a)2288(Map(a)1101223002 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{0002447B-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.XmlMap";Url(a)1101223001 : Text[1024];Result(a)1101223000 : Integer); BEGIN END; EVENT XlWrkBk2(a)1101223040::RowsetComplete(a)2610(Description(a)1101223002 : Text[1024];Sheet(a)1101223001 : Text[1024];Success(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkSht2(a)1101223041::SelectionChange(a)1543(Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range"); BEGIN END; EVENT XlWrkSht2(a)1101223041::BeforeDoubleClick(a)1537(Target(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range";VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkSht2(a)1101223041::BeforeRightClick(a)1534(Target(a)1101223001 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range";VAR Cancel(a)1101223000 : Boolean); BEGIN END; EVENT XlWrkSht2(a)1101223041::Activate(a)304(); BEGIN END; EVENT XlWrkSht2(a)1101223041::Deactivate(a)1530(); BEGIN END; EVENT XlWrkSht2(a)1101223041::Calculate(a)279(); BEGIN END; EVENT XlWrkSht2(a)1101223041::Change(a)1545(Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020846-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Range"); BEGIN END; EVENT XlWrkSht2(a)1101223041::FollowHyperlink(a)1470(Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00024431-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.Hyperlink"); BEGIN END; EVENT XlWrkSht2(a)1101223041::PivotTableUpdate(a)2156(Target(a)1101223000 : Automation "{00020813-0000-0000-C000-000000000046} 1.6:{00020872-0000-0000-C000-000000000046}:'Microsoft Excel 12.0 Object Library'.PivotTable"); BEGIN END; BEGIN END. } } ===================== "PSM" wrote: > I'm trying to copy a sheet from one book to another by a codeunit in Navision. > If you did it in Excel you'd use: > - Sheets("sheet name").Select > - Sheets("sheet name").Copy After := WorkBooks("book name").Sheets(sheet > number) > In Navision, you can only use > - Sheets.Copy('After); > Do anyone know how can I do it? > Thanks. |