Yourbeliefs

Ok.. I'm undertaking a major project with Word files. I'm looking to convert my dad's old method of writing appraisals, which is basically him writing down everything, shipping it over to his typist (who just modifies some existing documents with the new information), who then emails it back to him, and I go and throw in all the exhibits (photos, legal papers, etc.) This is not very efficient. My goal is to write a C# program (.Net 2.0 Visual Studio 2005) that will basically generate these reports for him, where he just writes in various lines in text boxes that are used as variables, loading in photos to be automatically dropped in and resized, and stuff like that. The thing is that there are A LOT of different things that need to come together in terms of content and such, and there is quite a bit of "static" text that does not change from report to report. I've just started on this project, and while I am sure to have numerous extra questions about how to handle various things, my first thing is I'm wondering how I should deal with all this static text. The way I see it is I have 3 options in terms of merging all these various blocks of text. I can either:

A. Hard Code it, or rather put it in a module or something easily editable, but do it within the program itself, thus resulting in huge strings that are built into the program but are also customizable with the Interop word class.
B. Import it from Text Files and then try to clean it up when it comes in for display in the word file. I'm not sure though if doing this will allow me to work with all the characters, because when I first tried that it had problems displaying quotation marks and such (the black " " symbols)
C. Merge a bunch of pre-formatted smaller word files and bring them into the final document that will be created.

Does anyone have any ideas or suggestions as to how I should approach this issue Any help would be GREATLY appreciated. If I can pull this off I will save my business alot of money in outsourcing and travel fees. Also it will basically give us the advantage of having a 24-48 hour turnaround time with our reports, which in our business is a major asset with added productivity and more chances to make more money.

Again, all help appreciated, thanks.

-Dave

P.S. Since this seems to be the next big issue I'll have.. does anyone have any ideas as to how to load up a JPEG in C#, which will then resize it to a given dimension and then transfer that to the word file (WITHOUT saving the new smaller image.) After it is done I just want it to scrap it, because having a bunch of 3.5 X 5.5 image files while still having the higher res versions in my opinion is just counter productive.
Ok now my letter is over. Thanks

-Dave again.


Re: Visual C# Express Edition Merging Multiple Word Files with C#

Derek Smyth

Hi Dave,

What version of Word are yous using

Word documents are changing. They are changing from really difficult to read binary format to an XML format (WordML), Office 2007 comes with another format, OPC (Open Package Convention) which is also based on WordML. The .NET framework has EXCELLENT support for XML. If you where to work in WordML rather than native binary format it will make your project much more easy to achieve.

You don't even need to use Word at all, you can do all the document processing in your own program. As to your static text you can store these in XML files, like mini word documents, loading them in as required and appending them to the main documents XML.

Of course there might be a learning curve, but I believe that if you took this approach you and your dads company will benefit from it.






Re: Visual C# Express Edition Merging Multiple Word Files with C#

Yourbeliefs

I'm using Word 2003. I found Word 2007 to be clunky and unintuitive.




Re: Visual C# Express Edition Merging Multiple Word Files with C#

Derek Smyth

Thats ok, WordML is supported in 2003 however there might be an update to your application if Word 2007 is used, I have never used 2007 so don't know how backward compatible it is...

This will get you started with an Hello World sample....

Overview of WordprocessingML [Word 2003 XML Reference]

http://msdn2.microsoft.com/en-us/library/aa212812(office.11).aspx

...think like this WordML is to Word what HTML is to a web browser.

There is a download here that contains a help file and schemas for WordML 2003, you need to download this if you go this route.

http://msdn2.microsoft.com/en-us/library/aa214923(office.11).aspx

It's important that you think in terms of XML and not Word. It's a different way of thinking. The XML forums here on MSDN is a brilliant reference for XML and .NET, for example one of the things you'll need to know is how to merge two XML documents, or how you can query an XML document. Thats the place to ask, there are some helpful people there.






Re: Visual C# Express Edition Merging Multiple Word Files with C#

Yourbeliefs

In your opinion, do you think this is easier to use than using the Office Interop system Also, is there a decent amount of literature out there on this WordML Also I will be using numerous variables with this program, as there are some strings and such that are used in multiple parts of the reports that I will be referencing.




Re: Visual C# Express Edition Merging Multiple Word Files with C#

Derek Smyth

There is a good amount of information about the Office 2007 format, but apart from the SDK download the information on WordML in 2003 could be better. Word2003 is reasonably complete compared to the other Office XML languages but I do think that this is the best approach to take. Is it easier that depends on yourself, what you feel comfortable with, what you know of XML, and what you want to do in the project, where the project will go in the future, if your comfortable taking on new technology, how much time you have.

I always see native Word documents as locking data away into a difficult to read format, I've experienced it more with Excel in which masses of data is locked away and difficult to access. With the XML approach your working with structured data that is text based, you can use the XML classes of .NET to merge the document parts together, you can replace certain placeholders in the document, and generally there is more freedom and flexibility. I have good knowledge on XML and it's related technologies so I know whats possible with it and there is a lot you can do, basically I'll only ever store data in XML format, if the project allows it.

Also I prefer to stay away from Interop with any application, if I can help it. Interop binds your application with the other application creating a relationship that is difficult to break and dependent on versions, esp the version of the other application, which you have no control over. For example if you do go to Office 2007 or a less chunky Office 20 then your Interop will need to change, there is no guarentee your application will work over time. It's the same with WordML but it's the scale of the work needed to update your application to the new version of the other application.

You have to judge what you think would be the best approach giving your knowledge, the project, time and of course how much money is available to do the project.






Re: Visual C# Express Edition Merging Multiple Word Files with C#

Derek Smyth

Hi, I'll create you a small demo application that merges xml based word documents and you can use that to determine if it's suitable for you project.






Re: Visual C# Express Edition Merging Multiple Word Files with C#

Yourbeliefs

Thank you so far for all your ideas and alternatives with this. Just to start off, here's what I'm working with as far as the project goes:
No budget (except for picking up programming books.)
No real time limit (I want this done by November.)
No staff/support (my business is me and my dad.) He does the appraisal work, and I do the technology side. Before I came on he was getting reports back from his typist and pasting photos from Walgreens, and then taking exhibits, putting them in the photocopier, then taking that copy and cutting it out and pasting it onto the report. Then, for location maps he would go through his big book of maps, then take those transparencies with stuff you rub onto things to mark off locations, and finally, because these were so time sensitive he would have to overnight the reports down to Florida (We live in CT.) All of that I converted to digital format.
This project started off with me trying to do it with templates, but I just could not find alot of good information about that. Then it went to VBA, but I was just getting no where fast with that because I have no experience with VBA and for whatever reason I haven't been able to bridge that small gap between VB and VBA programming. Then it went to C#, which I really like programming in (my college professor was wise to teach us that in my opinion) but I was running into interop issues in terms of being able to customize everything easily and not running into writing excess code to get it to look the way I want.

Again thank you for your help so far, and do you know if WordML allows for using images like JPEGs and customizing their size within the WordML file, as opposed to having to do it after it is imported




Re: Visual C# Express Edition Merging Multiple Word Files with C#

Derek Smyth

Hi, how you doing

First of all I've created a project for you and this approach might work, I'm having problems with embedding an image. It's strange the image is there and is displayed in a version of OpenOffice that I have in the house but it doesn't display in Word here in work, it will be a minor thing. I know this is a big part of what you want to do so I'll get that working before sending you the example.

Yes, just checked, you will be able to customise the image size, there is width and height.

Edit: The image problem is fine, you can embed images into a document no problem.

To be honest I think we need to have a chat on messenger sometime this weekend, I'm in Glasgow, Scotland so how far behind Greenwich are you Let me know and we'll arrange a time. Think it will be worthwhile for yourself, I'll talk you through XML, how the example works, and give you some direction if you decide to go this way.

Here is some more information on Office XML

http://www.oreilly.com/catalog/officexml/chapter/ch02.pdf

http://rep.oio.dk/Microsoft.com/officeschemas/wordprocessingml_article.htm

I've looked into some other potential approaches, Visual Studio Tools for Office (VSTO) which are a set of tools for developing Office Addins in C# (what you tried to do with VBA) and these to would be a good approach but unfortunately I don't know if you can get them with Express editions. You'd need to find that out, there should be a VSTO forum. I have never used them so I can't really offer any additional assistance with them.

Let me know when your available to chat ok.






Re: Visual C# Express Edition Merging Multiple Word Files with C#

Yourbeliefs

I'm in the eastern Time Zone, so I believe that makes me -5 off of GMT.
Honestly I'm more available during the end of the week as opposed to the weekend.. or rather.. for this weekend. Saturday is my birthday and I'm of legal drinking age (draw your own conclusions) and Sunday I spend the entire afternoon watching American Football, so I guess I would say I'm free between 9am to 5pm on Thursday and Friday, between 8am and 2pm on Saturday, and 9am to 1pm Sunday (all these times listed are in my local time zone Eastern.) Also on thursday I'd have to work Remotely, so my performance and response time will not be as good as if I was right at my machine.
Again thank you for all this help so far. I'm looking to knock my dad's socks off, and potentially get some more money by distributing the program to other appraisers. We got burned a while back by this BS company called @Value that tried to do something similar to this but in all macros and VBA and it just didn't work out very well. Very clunky, slow loading, and information constantly was not transferring over. That's why the working title (and soon to be final title) of this will be F@Value (You can either pronounce it as "Fat Value," or do it out, which is "F- @Value.") Again thank you so far for your help.




Re: Visual C# Express Edition Merging Multiple Word Files with C#

Derek Smyth

Friday would be good for me. If your about 10am your time or there abouts I should be on, my MSN handle is dsmyth at ntlworld dot com (i think, don't chat that often, leave your handle just encase yeah). Everything that I know you'll need, adding paragraphs, template paragraphs and inserting images is all in the example and works so I'll talk you through a bit of XML and then the sample (which is really easy). It might not do everything you need but will be a good start, and the more I think about it the more I think this is the way to go.

Unfortunately with IT companys, or bespoke vendors, you never really know what your getting until it's to late because they all talk the talk and it sounds impressive but it doesn't mean they can deliver. They charge a fortune for the pleasure as well. The industry is full of cowboys, so is every industry really. I'd be careful of copyright infringement with the name of the software but the idea is sound. I call my work software names that have interesting acroynms like the Time Information Totalling System, nobody notices.

No worries about the help the start of the project is the most important part. If you take a wrong turn at the start it can become impossible (or nearly impossible) to change it. This WordML approach is a good approach because Office 2007 (and onwards) will use WordML, or an updated version of it, so there might still be changes but at least they won't be impossible (or expensive) changes.

Get a copyof XmlNotepad2007, do a search on MSDN and you'll find it, also have a pen and some paper so you can write stuff down to, and I'll chat to you Friday.






Re: Visual C# Express Edition Merging Multiple Word Files with C#

Derek Smyth

One other thing, if you have a microphone that would be good as well. Much easier and quicker to talk that to type.






Re: Visual C# Express Edition Merging Multiple Word Files with C#

Yourbeliefs

I don't really use messenger at all, so as far as my SN goes, if its the email address is davemaisano at that free email service that microsoft provides that is Hot. I'll try and get a microphone for my computer. Hopefully my system performance won't be too bad with the remote log in I need to do. 10am on Friday works for me. Thanks again for all your help so far.