简体   繁体   中英

VBA Read-only when Opening Excel from Outlook

I tried to open an excel file from Outlook but I can only open it in Read-only mode. I wrote this code:

strFile = "C:\Users\My File.XLSX"  
Set sourceWB = XLApp.Workbooks.Open(strFile, True, False)

But it didnt work.

I would like to open it in Read mode.

Thank you very much in advance,

Lorenzo

Your syntax is ok. I think the problem is that 'C:\\Users\\' is a System Directory and NTFS restricts to readonly. Try putting the file in a different location. for example '%UserProfile%'

There is an attribute for read-only. If you set the attribute to vbNormal it should open normally. But you have to set it before the file opens.

SetAttr "C:\Blank.xls", vbNormal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM