Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Can only open Read-Only Word documents from Excel using VBA

On Aug 13, 10:53 am, "Dave.Punk.Emo" wrote:
On Aug 6, 7:35 pm, "Bob Phillips" wrote:





Sounds like you may already have created aWordinstance and opened that
file.


Cheek ifWordis already running.


--
HTH


Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)


"Dave.Punk.Emo" wrote in message


roups.com...


Ok, I'm trying toopenand update a MSWorddocument fromExcelusing
VBA, but everytime I try toopenit, it loads as a Read Only Document,
giving me the message that this file is locked for use by myself, and
thus not allowing me to save it. I'm using this code toopenit (the
SendKeys does not appear to make any difference to this message):


Sub Button13_Click()
Dim wdApp As Object
Dim wdDoc As Object
Dim sFname As String


sFname = "R:\SALES\Quote Generators\Quotes\2 Pass Tray\2 Pass Tray
Quote.doc" 'File Location


If sFname = "R:\SALES\Quote Generators\Quotes\2 Pass Tray\2 Pass
Tray Quote.doc" Then


Set wdApp = CreateObject("Word.Application")
wdApp.Documents.OpenFilename:="R:\SALES\Quote Generators
\Quotes\2 Pass Tray\2 Pass Tray Quote.doc" 'Opens File
SendKeys "{Left} {Enter}, False" 'Updates File
End If
End Sub


Can anyone help me to be able toopenit as a non-read-only file...?- Hide quoted text -


- Show quoted text -


What seems to happen is the first time the code is executed, it
creates an instance ofword, and the second time it is executed, it
opens the file, as read only. Any ideas on how to fix this?- Hide quoted text -

- Show quoted text -


I managed to fix it by changing the code to:


Sub Button13_Click()
Dim wdApp As Object
Dim wdDoc As Object
Dim sFname As String

sFname = "R:\SALES\Quote Generators\Quotes\2 Pass Tray\2 Pass Tray
Quote.doc" 'File Location

If sFname = "R:\SALES\Quote Generators\Quotes\2 Pass Tray\2 Pass
Tray Quote.doc" Then

Set wdApp = CreateObject("Word.Application")

wdApp.Documents.Open Filename:="R:\SALES\Quote Generators
\Quotes\2 Pass Tray\2 Pass Tray Quote.doc" 'Opens File
wdApp.Visible = True 'Added this
lline of code
SendKeys "{Left} {Enter}" 'Updates File
End If
End Sub


Thanks for all the help

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read/write excel and word 2007 documents from another application mco3006 Excel Discussion (Misc queries) 0 April 27th 10 10:18 AM
Possible to open word documents in Excel using hyperlinks? DobieM New Users to Excel 2 July 12th 06 04:08 PM
how do you get Word to open documents in it's own window(s)? othree7 Excel Discussion (Misc queries) 0 November 16th 05 04:21 PM
Can't open excel or word documents (says insert sm bus cd?) Angela27 Excel Discussion (Misc queries) 0 June 20th 05 07:31 PM


All times are GMT +1. The time now is 08:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"