Hi, i'm very new with visual basic.
Would like to know if it's possible to control a software. For example, open Word, type some words in a document, go to the edition menu, change the font, and then save the document ?
How would it be done ?
Printable View
Hi, i'm very new with visual basic.
Would like to know if it's possible to control a software. For example, open Word, type some words in a document, go to the edition menu, change the font, and then save the document ?
How would it be done ?
Welcome to the forums. :wave:
Set a reference to the Microsoft Word Object Library. Run thisType whatever you want to type, do whatever you want to do, then click on the File/Save menu from Word.VB Code:
Dim objWord As Word.Application Set objWord = New Word.Application objWord.Visible = True objWord.Documents.Add
hum,... no. I want my little vb program to 'click on the file/save menu' from word and save the document. I want to know if litteraly I can 'control' a software, as if the mouse was moving all by itself.
you may use Hack's suggestion for opening Word App and then use SendKeys function for Saving the document.Quote:
Originally Posted by lepetitcrabe
There is a way... I made a program that does something like that. It was basically for an automated learning presentaion that shows you literally what to click, where to click and to an extent HOW to click it and the results...
BUT trust me.. it's not that easy... it requires getting the classname, title and handle of the window... enumerating through all the windows... getting the mouse cursor position and setting it... and the toughest of all... making sure the user does not move the mouse cause you will get a little mouse struggle...
SO unless you're an expert in VB then I suggest going for the simple and referencing MSWO Library as Hack said...
If I can still get my hands on the coding I used I'll upload it...
Using the reference Hack has given, it is possible to call the Save function.
Unless you really want to 'control' the mouse, but that will be harder.
You'll have to determine the position of the menu first.
Exactly!Quote:
Originally Posted by vbcode1980
You can use either a FileSaveAs or a FileSave right from within your code.