This program requires a reference to the Word object model. Select Project/Add Reference. Click the COM tab and select "Microsoft Word 11.0 Object Library" (or whatever version you have on your system).
When you click the Open button, the program creates a Word server and opens the document. It sets the document's RemovePersonalInformation property to True and saves the file. This removes the personal information from the file and makes the file not save that information in the future.
A slightly odd thing happens in this code. The call to Open takes a parameter declared as an Object. If you try to pass in txtFile.Text, Visual Basic complains that it cannot convert an Object into a String. But wait. You're trying to do the opposite: pass a String in as an Object variable. That should work because a String is a type of Object (it inherits from Object).
The trick is that this parameter is declared without the ByVal keyword. That means it is passed by reference and the Open routine might change the Object's value. It cannot do that if you pass it a String instead of an Object so it complains. A bit backwards but it makes some sense.
|