Choose Language Hide Translation Bar
SW
SW
Community Trekker

Save Powerpoint from within HListBox

Hi,

I'm trying to create a script to generate some output and the save a powerpoint (or not) based on user selection.  I can't get the "save presentation" command to work when it is nested within the H List Box structure. 

The first script works fine:

Names Default To Here( 1 );
dt1 = open(Pick File("Select the the DATA TABLE to open."));  //open a file

WinHandle2 = new Window("Graphs",Distribution(Column(2)));  //generate some output of interest							

product_name = dt1:Product[1]; //get the product name from the first cell in the data table

//OUTPUT report to a Powerpoint file (THIS WORKS FINE):
saveFilename=product_name ||"_Distribution_"||char(year(today())) ||"-"||char(month(today()))||".pptx";
WinHandle2 << Save Presentation(saveFilename, Outline Titles("TopLeft"));   //save the output to a Powerpoint file.

//prompt user to see if they want to save and close remaining windows.
w1 = New Window("What's Next?", text box("
       Save the report and Close the Data Table?
		"),       
       // Get user input,
       H List Box(Button Box("Yes",
			WinHandle2<<Close Window(nosave);	//close the window
                        dt1<<Close Window(nosave);			//close the data table
			w1 <<Close Window; 					//close this dialog box
        ),
			b = Button Box( "Exit", b << Close Window;
        )));

If I move the "Save Presentation" command inside the H List Box, I get an error "Error writing presentation file. Unable to open in ReadWrite mode. The system cannot find the file specified".  See the non-working code below:

Names Default To Here( 1 );
dt1 = open(Pick File("Select the the DATA TABLE to open."));  //open a file

WinHandle2 = new Window("Graphs",Distribution(Column(2)));  //generate some output of interest							

product_name = dt1:Product[1]; //get the product name from the first cell in the data table


//prompt user to see if they want to save and close remaining windows.
w1 = New Window("What's Next?", text box("
       Save the report and Close the Data Table?
		"),       
       // Get user input,
       H List Box(Button Box("Yes",
		//OUTPUT report to a Powerpoint file (THIS WORKS FINE):
		saveFilename=product_name ||"_Distribution_"||char(year(today())) ||"-"||char(month(today()))||".pptx";
		WinHandle2 << Save Presentation(saveFilename, Outline Titles("TopLeft"));   //save the output to a Powerpoint file.
		WinHandle2<<Close Window(nosave);	//close the window
                dt1<<Close Window(nosave);			//close the data table
		w1 <<Close Window; 					//close this dialog box
        ),
		b = Button Box( "Exit", b << Close Window;
        ))
);

Basically, I want the user to choose if the presentation should be saved, or just exit.  Thanks in advance for your help

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Save Powerpoint from within HListBox

Here is one way to do this:

Names Default To Here( 1 );
dt1 = Open( path = Pick File( "Select the the DATA TABLE to open." ) );
pathToFolder = Left( path, Contains( path, Word( -1, path, "\/" ) ) - 1 );
Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Save Powerpoint from within HListBox

The issue is that the path/file name that you are passing to the Save Presentation is pointing to a folder that does not exist, or does not have write previliges to.  I received the same message when running your code, and then I added to the product_name value, a path to a writable direectory and and then the code worked fine.

Jim
0 Kudos
SW
SW
Community Trekker

Re: Save Powerpoint from within HListBox

Thanks for the reply.  It's strange that the first set of code (where the save presentation is outside of the H List Box) runs fine.

 

In the upper code, the file saves to the last active directory. (the location where the script is run from and the input data file is located).  How can I do this with the H List Box version of the code?

0 Kudos
txnelson
Super User

Re: Save Powerpoint from within HListBox

Here is one way to do this:

Names Default To Here( 1 );
dt1 = Open( path = Pick File( "Select the the DATA TABLE to open." ) );
pathToFolder = Left( path, Contains( path, Word( -1, path, "\/" ) ) - 1 );
Jim

View solution in original post