Re: Opening Excel Workbook from Word using VBA - Always Read Only by JGM
JGM
Tue Nov 04 23:54:28 CST 2003
Hi Alan,
Try changing
>Set wrk = xls.workbooks.Open(FileName:=xlfilename, Updatelinks:=0, _
> ReadOnly:=False, Password:="password")
for
Set wrk = xls.workbooks.Open(FileName:=xlfilename, Updatelinks:=0, _
WriteResPassword:="password")
If your original code opens the workbook all it means that it is not
protected against opening it, but against modification, which is a different
password. If you have two passwords, you will have to include both in the
arguments, even if it is the same password for opening and for modification.
Something like:
Set wrk = xls.workbooks.Open(FileName:=xlfilename, Updatelinks:=0, _
Password:="password", WriteResPassword:="password")
If you decalre both password like this, You do not need the ReadOnly
argument. Actually, the ReadOnly argument is to give you the option to open
a document through code and make it "Read Only" even if it has not been
protected by a password... In fact, without the password argument, the
ReadOnly argument is useless, and if you supply a password, why bother with
a ReadOnly argument... see what I mean?
Anyway, just my 2 cents!
HTH
Cheers!
--
_______________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca
"Alan" <alan@alan.alan> a écrit dans le message de news:
uUEAGQ1oDHA.1960@TK2MSFTNGP12.phx.gbl...
> "Jezebel" <grocer@play.net> wrote in message
> news:eZuQqH1oDHA.1948@TK2MSFTNGP12.phx.gbl...
> >
> > Have you checked in Windows Explorer to see if the file itself is
> > read only (came off a CD perhaps)?
> >
>
> Hi Jezebel,
>
> I should have stated up front that I had in fact checked that, but
> good point to ask nevertheless.
>
> Unfortunately, it is not that simple an answer for me!
>
> Any other ideas?
>
> Thanks,
>
> Alan.
>
>
>