Access Newbie wrote: > > I have a series of data requests that I partially automate through > ArcGIS and python scripting. The only hurdle I am really struggling > with is how to get the excel tables into the word document. Right now > I can run the analyses, format the results into paragraphs with the > text that I want, and output the maps in pdf format. The pywin32 > package has allowed me to execute the excel macros that import the dbf > files, reformat the data in the tabular format I want, and export out > to an xlsx workbook. To have the process completely automated, I > would need to also load the excel tables into the word document. This > is where I am at a complete loss. I haven't a clue as to where to even > start to accomplish this. Could you please take a quick look at my > post and let me know if this is doable, and if so, point me in the > right direction as to how to accomplish this? >
There are a couple of options. None of them are particularly easy. You probably have some frustrating experimentation coming up. The easiest option, if your data does not have to be "live", is to convert the Excel cells to a Word table. A table is just another Word object, like a paragraph or a word. You can figure out the APIs to insert the table and update the cells. If the Excel data needs to be "live", so that the Word document updates automatically when you change the spreadsheet, then you are into the world of OLE -- Object Linking and Embedding. You would need to embed the hooks to the Excel spreadsheet into the Word document. To do that, you'll need to add a ChartData object to the InlineShapes collection in the ActiveDocument. I have never done this, although here is an example in VBA that might get you started: http://msdn.microsoft.com/en-us/library/office/ff821389.aspx -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc.
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32