vb.net - How to make sure a file is closed before renaming it -


I am opening Word document using Appwords.documents.open and closing them with appword.quit. Then in the function named Processa, the name of the application document changes.

The problem I am getting is that the file has not been closed before changing the name of the file. How can I ensure that the document of the word is closed before trying to rename it is?

  WordDoc = AppWord.Documents.Open (filepath + filename) txtFileContents.Text = WordDoc.Content.Text AppWord.Quit () Process Data (txtFileContents.Text, filepath, filename)   

This is what gives the document the name in the processata function:

  My.Computer.FileSystem RenameFile (fPath + fName, NewName + ".doc")   

You should not just use the Skip Application () method to close the document . Usage:

  WordDoc.Close WordDoc = nothing   

Call the exit method again.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

c# - passing input text from view to contoller with FacebookContext using Facebook app -

Calling a C++ function from C# by passing a string with variable size to it -