Bazenga Posted January 15, 2010 Share Posted January 15, 2010 Hello everyone, I'd like to start doing some coding to interact with Office documents, specially Excel and Word. I tried to start a new project with office template but I was ..... lost, completely. Any ideas on how to actually start? Thanks. Link to comment Share on other sites More sharing options...
0 Bazenga Posted January 19, 2010 Author Share Posted January 19, 2010 *bump*, the replies are lost because the forum error. Anyone? Link to comment Share on other sites More sharing options...
0 biorK Posted January 19, 2010 Share Posted January 19, 2010 Unfortunately working with Excel spreadsheets and Word documents can be, imo, a pain in .NET. You need to use a COM Interop for the specific program you're targeting (ie. Excel or Word). It will be easier once .NET 4.0 is released this spring with the new dynamic keyword, but that doesn't help you atm :) My recommendation is to read about using Interops (here, here, most good articles is on MSDN) or if you have the cash to use something like Aspose, it's a delight working with, but it costs around 900$ per license. Link to comment Share on other sites More sharing options...
0 maxdee Posted January 24, 2010 Share Posted January 24, 2010 I've done already some office developing using the microsoft interop assemblies. you can install these assemblies with your office installation (must be somewhere within the advanced options) or you start searching for them and download them somewhere. Put the assemblies somewhere on your harddrive and reference them within your project. Than you can start developing. If you want, I can paste some outlook code in here, just to see how you start. But I suggest, google around. There is a lot of code about office developing. Link to comment Share on other sites More sharing options...
0 Bazenga Posted January 25, 2010 Author Share Posted January 25, 2010 All right, thanks everyone. I'll try to see around. The idea is that a WinForm with a lot of fields and all those information must be written to a word document (the world template is already there, I have to fill in the winform data and write them to it) and then print it out. Link to comment Share on other sites More sharing options...
0 maxdee Posted January 25, 2010 Share Posted January 25, 2010 a small code snippet... oWordApplic = null; try { object wdObject = Marshal.GetActiveObject("Word.Application"); oWordApplic = (Microsoft.Office.Interop.Word.Application)wdObject; } catch {} if (oWordApplic == null) { try { oWordApplic = new Microsoft.Office.Interop.Word.ApplicationClass(); } catch {} } object missing = System.Reflection.Missing.Value; object template = System.Reflection.Missing.Value; if (sTemplate.Length > 0) template = sTemplate; oDoc = oWordApplic.Documents.Add(ref template, ref missing,ref missing, ref missing); oDoc.Activate(); oWordApplic.Selection.TypeText(strText); object missing = System.Reflection.Missing.Value; object fileName = strFileName; oDoc.SaveAs(ref fileName, ref missing,ref missing, ref missing,ref missing,ref missing,ref missing, ref missing,ref missing,ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); Link to comment Share on other sites More sharing options...
Question
Bazenga
Hello everyone,
I'd like to start doing some coding to interact with Office documents, specially Excel and Word. I tried to start a new project with office template but I was ..... lost, completely.
Any ideas on how to actually start?
Thanks.
Link to comment
Share on other sites
5 answers to this question
Recommended Posts