open export to web dialog

S

Stanley

Hi,

i want to open de "export to web" programmatically. I found (only one)
article/answer which stated that it wasn't currently possible to do that.
That answer dated from april 2005. As we are 10 months further i wonder if it
is now possible with a new service pack of some other kind of method.

Thnx,

Stanley
 
B

Ben Walters

Hey Stanley,
The Export to .MHT (web) option can be called from code using the following
code (note however if you are writing files to the users machine you will
need to digitally sign the form or deploy it using th reg form utility all
found in the SDK)

XDocument.View.Export("c:\MyForm","MHT");

Cheers
Ben walters
 
S

Stanley

Ben, thanks for your response. But this piece of code has the save location
hardcoded. I would like to have the user choose their own save location.
I also looked into the digital signature thing and i don't understand
exactly what it says or what to do, but it seems like lots of work for just
to save a file locally.

My situation is, i have a form on sharepoint. Users can use this form to
enter data into a database. But sometimes they would like to have a copy of
the form before submitting. A copy is not stored in sharepoint, that's why
they have to save their own copy. They could use the "file\export to" menu
option, but appearantly they are not "that smart", so we would like to give t
hem a button to click on.

Thanks,

Stanley
 
B

Ben Walters

Stanely,
Correct this code does contain a hard coded path, however if you add a
reference to System.Windows.Forms, you can then show the user the save dialog
from here they can select a path and click save you can then take the
returned path and use it in your export function. Check the code below for
more details

Assuming you have a reference to System.Windows.Forms

public void button1_OnClick(DocActionEvent e)
{
//Create the Save dialog object
System.Windows.Forms.SaveFileDialog MySaveDialog = new
System.Windows.Forms.SaveFileDialog();

// set the default file type to save the file as
MySaveDialog.DefaualtExt = "mht";
MySaveDialog.Filter = "MHT | Microsoft HTML File"
MySaveDialog.ShowDialog();

e.XDocument.View.Export(MySaveDialog.FileNames[0].ToString(),"MHT");
}

As for Signing the form, basically the rule is this. If your form is
attempting to write files to a users machine or access resources on a users
machine then it will need to be either digitally signed using a certificate
generated by a trusted source VeriSign is a good place to get a certificate
if you don't have your own certificate server. The other option is to use the
RegForm util that is included in the SDK this is a command line utility that
can set the form to a full trust level hence enabling it to access files on
the users computer. However as you are publishing this form to share point a
digital Certificate may be a better idea.
 
S

Stanley

Ben,
Calling the save dialog is a great idea to retrieve the file and location
name, but still i have to save the form locally in code which is not allowed.
A better idea would be calling the menu option "File\Export to\Web" which
opens the "export to" dialog box. Is it possible to call menu items in code?
In Access for example you can call menu items in code. If that is possible,
my problem would be solved.

I don't want to use certificates. If i'm not mistaken when opening the form
each time a dialog box will open which asks the user if he/she accepst the
certificate. We don't want to bother the users with this question. The users
of these forms are quite "stupid" (sorry people :) ) when it comes to using
such programs. They just want to click a button and save the document.

So if there is a way to call menu items, that would be great otherwise,
we'll just leave it like this.
Thanks for your effort.

Stanley


Ben Walters said:
Stanely,
Correct this code does contain a hard coded path, however if you add a
reference to System.Windows.Forms, you can then show the user the save dialog
from here they can select a path and click save you can then take the
returned path and use it in your export function. Check the code below for
more details

Assuming you have a reference to System.Windows.Forms

public void button1_OnClick(DocActionEvent e)
{
//Create the Save dialog object
System.Windows.Forms.SaveFileDialog MySaveDialog = new
System.Windows.Forms.SaveFileDialog();

// set the default file type to save the file as
MySaveDialog.DefaualtExt = "mht";
MySaveDialog.Filter = "MHT | Microsoft HTML File"
MySaveDialog.ShowDialog();

e.XDocument.View.Export(MySaveDialog.FileNames[0].ToString(),"MHT");
}

As for Signing the form, basically the rule is this. If your form is
attempting to write files to a users machine or access resources on a users
machine then it will need to be either digitally signed using a certificate
generated by a trusted source VeriSign is a good place to get a certificate
if you don't have your own certificate server. The other option is to use the
RegForm util that is included in the SDK this is a command line utility that
can set the form to a full trust level hence enabling it to access files on
the users computer. However as you are publishing this form to share point a
digital Certificate may be a better idea.

Stanley said:
Ben, thanks for your response. But this piece of code has the save location
hardcoded. I would like to have the user choose their own save location.
I also looked into the digital signature thing and i don't understand
exactly what it says or what to do, but it seems like lots of work for just
to save a file locally.

My situation is, i have a form on sharepoint. Users can use this form to
enter data into a database. But sometimes they would like to have a copy of
the form before submitting. A copy is not stored in sharepoint, that's why
they have to save their own copy. They could use the "file\export to" menu
option, but appearantly they are not "that smart", so we would like to give t
hem a button to click on.

Thanks,

Stanley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top