Logo 
Search:

MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

Populate a Word doc from InfoPath or SPD workflow?

  Asked By: Tracie    Date: Sep 17    Category: MOSS    Views: 3243

I need to generate a Word doc from a template. I have an InfoPath form that
submits to a SP doc library, then an SPD workflow calculates some things on the
back end to populate a DVWP. What would be the best way to fill in the Word doc?
I will be googling in the meantime, and will post back with anything I find.

Share: 

 

13 Answers Found

 
Answer #1    Answered By: Suresh Chindarkar     Answered On: Sep 17

I'm assuming that you are using WSS v3 or MOSS 2007. this may give you some
ideas to get started

blogs.technet.com/.../automatically-create-wo\
rd-documents-which-include-list-fields.aspx

 
Answer #2    Answered By: Varun Mehta     Answered On: Sep 17

Yes, using MOSS 2007. I will check that link.

I could save the file to the server or pop up it up and have thme save
it. Either way would work.

 
Answer #3    Answered By: Junior Jarvis     Answered On: Sep 17

The process at that link would work if I were just putting some fairly static
stuff in a doc, but what I need is all questions from my InfoPath form that got
"No" answers to be put into the doc. With the questions as well. I am looking
for a way to build a block of text in the workflow, then post that into the doc
maybe.

 
Answer #4    Answered By: Sanjay Lohar     Answered On: Sep 17

You can use a standard SPD workflow to create dynamic strings based
on values in the list item (I assume each question is a field). Once that's
done, and you've compiled the appropriate text into your "to be exported"
field, it would be fairly easy to craft a custom ASPX that takes the list
item and spits out the appropriate headers followed by your text -- which
the browser interprets as a Word doc. Give your users the appropriate link
to the file (this could be a calculated field or just a dynamic link in a
customized form) and you're in business.

 
Answer #5    Answered By: Mason Salazar     Answered On: Sep 17

if possible, i would be interested in looking at your code samples as
well.

 
Answer #6    Answered By: Jesus Davis     Answered On: Sep 17

it's been a crazy week, and I'm looking forward to another one
(good to be busy at work lately). I'm away from my main dev box, but the
basic idea is illustrated with this rudimentary code:

// Clear the current response headers and set them up to look like a word doc.
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset ="";

HttpContext.Current.Response.ContentType ="application/msword";

string strFileName = "SomeFileName"+ ".doc";
HttpContext.Current.Response.AddHeader("Content-Disposition",
"inline;filename=" + strFileName);

// Using the current site, get the List by name and then the Item by
ID (from the URL).
SPSite oSite = SPContext.Current.Site;
SPWeb oWeb = oSite.OpenWeb();
SPList oList = oWeb.Lists["MyListName"];
SPListItem oListItem = oList.Items.GetItemById(myListID);

// Build a string with the data -- format it with HTML if you like.
StringBuilder strHTMLContent = newStringBuilder();

// Here's where you pull individual fields out of the list item.

// Once everything's ready, spit it out to the client machine.
HttpContext.Current.Response.Write(strHTMLContent);
HttpContext.Current.Response.End();
HttpContext.Current.Response.Flush();


You can see from this how it's easy to generate a word document by altering
the headers sent to the browser. You can put a page like this in your 12
hive Layouts folder, and use the querystring to feed it a List name/ID and
an Item ID; then the only question is how you want the data to look in the
final document. Fire away if you have questions; I hope this gets you
moving in the right direction.

 
Answer #7    Answered By: Narasimha Kamane     Answered On: Sep 17

I can see so many ways to customize this approach.

 
Answer #8    Answered By: Fidel Crane     Answered On: Sep 17

Let me know if you come across any mistakes; I just slapped that
together without testing, but the concept is sound.

 
Answer #9    Answered By: Akshara Sanghavi     Answered On: Sep 17

I've put the steps in to build the string. It will be quite a lift to do this
with all questions. What is the max size for the string variable in the SPD
workflow?

 
Answer #10    Answered By: Aishwarya Dixit     Answered On: Sep 17

Aside from COM interop/Office automation in a custom workflow, I'm not sure
what your options are. You might be able to build the format from scratch
with the proper markup and header information.

Are you storing this on the server, or serving it up immediately, or both?
You could do some content header magic and send the client an impromptu Word
doc -- I've done it a lot with Excel and have even written a custom assembly
that takes a list view and generates a spreadsheet for SP2007/Office 2003
users.

 
Answer #11    Answered By: Indrajeet Patil     Answered On: Sep 17

OpenXML 2.0......................................

 
Answer #12    Answered By: Xavier Hopkins     Answered On: Sep 17

We have explored this quite a bit for a MOSS2007 site, and the answer depends
on what constraints you have, the major points being:
- is the form to be browser only or browser+application?
- are you very fussy or slightly fussy over the formated result?
- do you have a Word template to be used (read dot or dotx)?
- do you have the ability (read permission) to put code behind the form and
then publish it?
- can you restrict yourself to one version of Word (03, 07, or xx)?
- can you purchase & have installed 3rd party WebParts?

Anyway, we have the worst of each Q above. We opted to have a 3rd party
service firm add additional customization to a complicated form that we built.
It worked reasonably well, except it ran into a deep level glitch in Microsoft
thingys whereby when a long field (000's characters) hit a page break,
portions would get strangely deleted.

Never-the-less, we were pleased with their professionalism and efforts.
Please call if anyone wants the reference.

 
Answer #13    Answered By: Viviana Rollins     Answered On: Sep 17

1. browser + app
2. there is a format, but i think some variation is ok
3. i have a doc, but not a template
4. i have full control over the form
5. yes, word 2007 is the only version they will use
6. i have installed 3rd party webparts, but would prefer to limit that

 
Didn't find what you were looking for? Find more on Populate a Word doc from InfoPath or SPD workflow? Or get search suggestion and latest updates.




Tagged: