controlling other applications from VB.NET
-
Hi, I am trying to create a window application to control another application. At the moment I can only find info on how to open applications such as note pad and send strings to write in note pad. Let's say if I would like to do other things apart from just sending a string to notepad, how would I do it. For example if I want to run a specific program such as MS Word, and then I want to access one of the menus to perform a certain action such as changing fonts or input shape into the Word document. I would like to perform all this using the controls such as a button on a form in VB.NET, how can I do this? Any help would be greatly appreciated.
-
Hi, I am trying to create a window application to control another application. At the moment I can only find info on how to open applications such as note pad and send strings to write in note pad. Let's say if I would like to do other things apart from just sending a string to notepad, how would I do it. For example if I want to run a specific program such as MS Word, and then I want to access one of the menus to perform a certain action such as changing fonts or input shape into the Word document. I would like to perform all this using the controls such as a button on a form in VB.NET, how can I do this? Any help would be greatly appreciated.
Hello mrmathesw99! Well there is a couple of things to note here: To start various applications, you could use Process.Start. I have noticed however, that you mention you want to able to do many things with MS Word for example. In that case you could use Automation to do whatever you want with Word, Excel etc. So, what you need to do is to add a Reference To the Microsoft Word Object Library (Just click References in the Solution Explorer, and say Add Reference, Select the COM tab, and scroll until you find it) You can add references to all MS Office programs like that. Once that is done, you can create Word Apllication variables and manipulate Word through that. Amazing huh ¿ Here's a small sample : Dim SSWord As New Word.Application 'word application Dim SSWordDoc As Word.Document 'document object SSWord = DirectCast(GetObject(, "Word.Application"), Word.Application) SSWordDoc = SSWord.Documents.Add(, , 1, False) 'add a document SSWord.WindowState = SSWord.WindowState.wdWindowStateMaximize 'maximise word window SSWord.Activate() 'activate it SSWord.ActiveWindow.ActivePane.View.ShowAll = True 'show / hide symbols = true After using the Word objects, you need to set the Word Objects to Nothing And Quit it as well Hope it helps! H T G
-
Hello mrmathesw99! Well there is a couple of things to note here: To start various applications, you could use Process.Start. I have noticed however, that you mention you want to able to do many things with MS Word for example. In that case you could use Automation to do whatever you want with Word, Excel etc. So, what you need to do is to add a Reference To the Microsoft Word Object Library (Just click References in the Solution Explorer, and say Add Reference, Select the COM tab, and scroll until you find it) You can add references to all MS Office programs like that. Once that is done, you can create Word Apllication variables and manipulate Word through that. Amazing huh ¿ Here's a small sample : Dim SSWord As New Word.Application 'word application Dim SSWordDoc As Word.Document 'document object SSWord = DirectCast(GetObject(, "Word.Application"), Word.Application) SSWordDoc = SSWord.Documents.Add(, , 1, False) 'add a document SSWord.WindowState = SSWord.WindowState.wdWindowStateMaximize 'maximise word window SSWord.Activate() 'activate it SSWord.ActiveWindow.ActivePane.View.ShowAll = True 'show / hide symbols = true After using the Word objects, you need to set the Word Objects to Nothing And Quit it as well Hope it helps! H T G
Thanks HTG... I will give this a try with the application I'm trying to run and will see how it goes.