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

How can I add a seperate action listener to all 14 of my buttons at once that can determine player turn?(java) -

Simple file compression in C -

php - Sorting an multidimension array using usort fails -