1 Replies - 2271 Views - Last Post: 19 June 2013 - 02:39 PM Rate Topic: -----

#1 AnalyticLunatic   User is offline

  • D.I.C Lover

Reputation: 239
  • View blog
  • Posts: 1,073
  • Joined: 25-June 12

How to release word object in vba?

Posted 19 June 2013 - 09:01 AM

I have an Excel Workbook created with a Form Control Button that when clicked is supposed to open a Word Document Manual to assist users with the use of other From Controls in the workbook.

Sub OpenManual()
'Word.Application.Documents.Open "\\filePath\FormFlow To MSExcel\FeedSampleReport-Manual.docx"

'Open an existing Word Document from Excel
Dim objWord As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True

' Should open as the forefront

'Change the directory path and file name to the location
'of the document you want to open from Excel
objWord.Documents.Open "\\filePath\FormFlow To MSExcel\FeedSampleReport-Manual.docx"

Set objWord = Nothing

End Sub

I'm have few issues sadly :/

When I have one other word document open and click the button, the following occurs:

  • Manual opens in the forefront, but I immediately receive This file is in use by another application or user. (C:\Users\Me\AppData\...\Normal.dotm)
  • I press OK and receive the Save As dialogue.
  • Cancel out of the Save As dialogue and am presented my Manual document.
  • When I click the Red X to close the document, I receive Changes have been made that affect the global template, Normal. Do you want to save those change? I click No and the document closes.

If this document is the first instance of word I have opening:

  • The document opens.
  • As soon as code hits the objWord.Quit line the document immediately closes.
  • I am just wanting the document to open to the forefront allowing users to view the Manual for assistance when they need it, and let them close the document at their discretion.

I've tried a few different variations but nothing has solved my issue.

Is This A Good Question/Topic? 0
  • +

Replies To: How to release word object in vba?

#2 maj3091   User is offline

  • D.I.C Lover
  • member icon

Reputation: 330
  • View blog
  • Posts: 1,998
  • Joined: 26-March 09

Re: How to release word object in vba?

Posted 19 June 2013 - 02:39 PM

You could try using shell or shellexecute to open the document in word. See this link for more details.

Unless you need to do some automation interaction with word, I don't see any reason to use the word object.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1