I need to use the Microsoft.Office.Interop.Word namespace to extract if a Word document contains macros, and which ones. The MSDN documentation for this namespace doesn't give much information compared to the documentation on other .Net classes.
Where can I get more informations about this namespaces (examples, complete documentation, etc.). I already searched on Google and SO but didn't much information.
Here's where you can learn more about this for Office 2007/Office 2010: http://msdn.microsoft.com/en-us/library/dd925808.aspx
There is no good documentation. The only resources are the MSDN (quiet bad) and some blogs. Maybe you can find some information here: http://blogs.msdn.com/mshneer/
The correct answer is to check the Document.HasVBProject property.
To quote from the Remarks section: "This property is most useful in programmatically determining whether a document needs to be saved into a macro-enabled file format. If saved in another format, macros and code projects contained within the document may be lost."
Microsoft.Vbe.Interop is the namespace for VBA. (VBE is Visual Basic for Application Extensibility 5.3.) Keywords to help you search are
MSDN Search for VBProject will get you started. http://social.msdn.microsoft.com/Search/en-US?query=VBProject&ac=8.
The following article is for VBA, but it is easily converted. WD2000: Sample Macro to Return Macro and Procedure Names at http://support.microsoft.com/kb/262961.
The bulk of the documentation is in the VBA help file which ships with Microsoft Word - for Microsoft Word 2003 look for a file VBAWD10.CHM. Also check the Microsoft Office Visual Basic Reference (VBAOF11.CHM)
10 and 11 in the above are Word and Office version numbers - so your mileage will vary according to which version of Word you have installed. Also the naming isn't consistent in all versions of Word, so a search for everything VBA*.CHM will probably turn up most of the documentation you need.
These will answer most of your questions about the Word API.
Can't see an obvious way of finding the list of macros in an open document or template, however... Please add a comment to this answer if you do find a method, as I'd be interested to know.
(Note that every call can throw an exception when using Word interop. If Word has any modal dialog box open you'll get an exception, for example. Program accordingly).