vb.net - How do I locate a Word application window? -
i have vb.net test application clicks link opens microsoft word application window , displays document. how locate word application window can grab text it?
you can use word com object open work document , manipulate it. make sure add reference microsoft word first.
imports system.runtime.interopservices imports microsoft.office.interop.word public class form1 inherits system.windows.forms.form private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click dim strfilename string dim wordapp new microsoft.office.interop.word.application dim doc microsoft.office.interop.word.document try doc = wordapp.documents.open("c:\testdoc.doc") doc.activate() catch ex comexception messagebox.show("error accessing word document.") end try end sub end class
the doc object handle instance of word have created , can use normal options (save, print etc). can likewise wordapp. trick use macro editor in word record want do. can view in macro editor. give great starting point vb code.
also, sure dispose of word com objects @ end.
Comments
Post a Comment