Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Close Method not working with read-only text files

Status
Not open for further replies.

striker73

MIS
Jun 7, 2001
376
US
I have a Word document that is open and I want to close it with VBA code. I've been looking at the Close Method on MSDN and it says that:

Document.close SaveChanges:=wdDoNotSaveChanges

should do the trick, and it does, except when the file is read-only. Does anyone know the syntax for closing a read-only file without saving a new copy? Thanks!!
 
Ok forget it, I won't make the files read-only. How about this one though:

When a user does not have Word open and creates a mail merge document with my Access 2k application, the template document opens, the mail merge is made and the template closes.

However, when the template file is already open and the mail merge application is run, the new document is created fine, but the template prompts whether or not you want to save it.

I have the same code for both:

'After the mail merge
objWord.Activate 'Move the focus to the template
objWord.Close SaveChanges:=wdDoNotSaveChanges

Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top