Error message when opening a .doc file using excel macro

  • Thread starter GainesvilleWes via OfficeKB.com
  • Start date
G

GainesvilleWes via OfficeKB.com

Morning,
I have created a macro in excel that when the user clicks a "done" button a
word document is opened from a shared drive.
this is what i have so far:

------------------------------------
Dim x As String
Dim wordApp As Object

ThisWorkbook.Save

x = Range("A156")

Set wordApp = CreateObject("Word.Application")
wordApp.Documents.Open "\\Flcscsrv02\share\Mercury Transactions\Test Docs\
" & x & "\Test word document.doc"
------------------------------------

when i run the macro the first time, nothing happens. when i run it a second
time, i get the "File in Use" pop up.

Where am i going wrong here?
 
P

paul.robinson

Hi
Try

Dim x As String
Dim wordApp As Word.Application
Dim myDoc As Word.Document
ThisWorkbook.Save
x = Range("A156")
Set wordApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set myDoc = wordApp.Documents.Open "\\Flcscsrv02\share\Mercury
Transactions\Test Docs\
" & x & "\Test word document.doc"
myDoc.Activate

regards
Paul
 
G

GainesvilleWes via OfficeKB.com

Thank you Paul & Tim.

Both ways worked! You guys are great =)

Hi
Try

Dim x As String
Dim wordApp As Word.Application
Dim myDoc As Word.Document
ThisWorkbook.Save
x = Range("A156")
Set wordApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set myDoc = wordApp.Documents.Open "\\Flcscsrv02\share\Mercury
Transactions\Test Docs\
" & x & "\Test word document.doc"
myDoc.Activate

regards
Paul

Morning,
I have created a macro in excel that when the user clicks a "done" button a
[quoted text clipped - 21 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top