I'm trying to program a Button in Task Area which give me various options when selecting a .PDF file, e.g. open the PDF File with a specific program.
I tried but when clicking the button I get an Error in Line 84.. Can you help me out?
"use strict"; function OnNewShellUI( shellUI ) { /// <summary>The entry point of ShellUI module.</summary> /// <param name="shellUI" type="MFiles.ShellUI">The new shell UI object.</param> // Register to listen new shell frame creation event. shellUI.Events.Register( Event_NewNormalShellFrame, newShellFrameHandler ); } function newShellFrameHandler( shellFrame ) { /// <summary>Handles the OnNewShellFrame event.</summary> /// <param name="shellFrame" type="MFiles.ShellFrame">The new shell frame object.</param> // Register to listen the started event. shellFrame.Events.Register( Event_Started, getShellFrameStartedHandler( shellFrame ) ); } function getShellFrameStartedHandler( shellFrame ) { /// <summary>Gets a function to handle the Started event for shell frame.</summary> /// <param name="shellFrame" type="MFiles.ShellFrame">The current shell frame object.</param> /// <returns type="MFiles.Events.OnStarted">The event handler.</returns> // Return the handler function for Started event. return function() { // Shell frame object is now started. // Create some commands. var commandShow1 = shellFrame.Commands.CreateCustomCommand( "Nitro Pro" ); var commandShow2 = shellFrame.Commands.CreateCustomCommand( "FlexiPDF" ); var commandShow3 = shellFrame.Commands.CreateCustomCommand( "PDF Annotator" ); // Set command icons. shellFrame.Commands.SetIconFromPath( commandShow1, "png/nitropro.ico" ); shellFrame.Commands.SetIconFromPath( commandShow2, "png/flexipdf.ico" ); shellFrame.Commands.SetIconFromPath( commandShow3, "png/pdfannotator.ico" ); // Add a command to the context menu. // shellFrame.Commands.AddCustomCommandToMenu( commandShow1, MenuLocation_ContextMenu_Bottom, 0 ); // Add a commands to the task pane. shellFrame.TaskPane.AddCustomCommandToGroup( commandShow1, TaskPaneGroup_ViewAndModify, -110 ); shellFrame.TaskPane.AddCustomCommandToGroup( commandShow2, TaskPaneGroup_ViewAndModify, -110 ); shellFrame.TaskPane.AddCustomCommandToGroup( commandShow3, TaskPaneGroup_ViewAndModify, -110 ); // Hide the command. shellFrame.Commands.SetCommandState( commandShow1, CommandLocation_All, CommandState_Hidden ); shellFrame.Commands.SetCommandState( commandShow2, CommandLocation_All, CommandState_Hidden ); shellFrame.Commands.SetCommandState( commandShow3, CommandLocation_All, CommandState_Hidden ); // Register to listen to when new shell listings are created. shellFrame.Events.Register( Event_NewShellListing, getNewShellListingHandler( shellFrame, commandShow1 ) ); shellFrame.Events.Register( Event_NewShellListing, getNewShellListingHandler( shellFrame, commandShow2 ) ); shellFrame.Events.Register( Event_NewShellListing, getNewShellListingHandler( shellFrame, commandShow3 ) ); // Is there already a listing? If so then we need to hook into it as well. if (null != shellFrame.Listing) { getNewShellListingHandler( shellFrame, commandShow1 )( shellFrame.Listing ); getNewShellListingHandler( shellFrame, commandShow2 )( shellFrame.Listing ); getNewShellListingHandler( shellFrame, commandShow3 )( shellFrame.Listing ); } // Set the command handler function. shellFrame.Commands.Events.Register( Event_CustomCommand, function( command ) { // Branch by command. if( command == commandShow2 ) { //Get vault object var Vault = shellFrame.ShellUI.Vault; //Get select items var selectedItems = shellFrame.Listing.CurrentSelection; var selectedpath = Vault.ObjectFileOperations.GetPathInDefaultView( selectedItems.ObjectVersions.Item(0).ObjVer.ObjID, -1, -1, -1 ); var oShell = new ActiveXObject("Shell.Application"); var commandtoRun = "C:\\Program Files (x86)\\SoftMaker\\FlexiPDF 2022\\flexipdf.exe"; oShell.ShellExecute(commandtoRun,selectedpath,"","open","1"); } } ); }; } function getNewShellListingHandler(shellFrame, commandId) { /// <summary>Gets a function to handle the NewShellListing event for shell frame.</summary> /// <param name="shellFrame" type="MFiles.ShellFrame">The current shell frame object.</param> /// <returns type="MFiles.Events.OnNewShellListing">The event handler.</returns> // Return the handler function for NewShellListing event. return function(shellListing) { // Listen for selection change events on the listing. shellListing.Events.Register( Event_SelectionChanged, function(selectedItems) { // Sanity. if (false == shellListing.IsActive) { return false; } // Has the user got any object versions selected? if (selectedItems.ObjectVersions.Count == 0) { // Hide the menu item - there's nothing selected. shellFrame.Commands.SetCommandState( commandId, CommandLocation_All, CommandState_Hidden ); return false; } // Show the menu item. shellFrame.Commands.SetCommandState( commandId, CommandLocation_All, CommandState_Active ); // We succeeded; return true. return true; } ); }; }