Open As Readonly
I'm trying to get my macro to open a file as Readonly, but
all I can do is get it to open a file. When I look at the code that is created for opening, opening as readonly and opening as copy, it all looks exactly the same. |
Open As Readonly
I should add to this that I am actually importing a TXT
file, so the code uses Workbooks.OpenText, not Workbooks.Open I see that if I use WorkBooks.Open, I can use ReadOnly:=True, however this doesn't work for Workbooks.OpenText -----Original Message----- I'm trying to get my macro to open a file as Readonly, but all I can do is get it to open a file. When I look at the code that is created for opening, opening as readonly and opening as copy, it all looks exactly the same. . |
Open As Readonly
usually
workbooks.open "filename/path", true/false (for read only), true ' true for read only works for me. Keith www.kjtfs.com --- Message posted from http://www.ExcelForum.com/ |
Open As Readonly
Ths code will do what you want, just replace the full file
name in the quotes. If you look at the VBA help for the Open method, you'll see that you can add qualifiers to the basic command to do pretty much anything you might want to when opening a file. workbooks.Open filename:="C:\amendments.xls",readonly:=true Cheers, Pete -----Original Message----- I'm trying to get my macro to open a file as Readonly, but all I can do is get it to open a file. When I look at the code that is created for opening, opening as readonly and opening as copy, it all looks exactly the same. . |
Open As Readonly
Unfortunately, my followup message didn't get posted fast
enough, explaining that I'm importing a file, and therefore using Workbooks.OpenText and not Workbooks.Open. Thanks to both of you, however, for your suggestions. -----Original Message----- usually workbooks.open "filename/path", true/false (for read only), true ' true for read only works for me. Keith www.kjtfs.com --- Message posted from http://www.ExcelForum.com/ . |
Open As Readonly
I think you'll find that you have opened it readonly
because a text file opened by Excel can still be opened using NotePad (for instance). I think this is the case because the text is "loaded" into an empty workbook. If you were to open the file using the VBA code, then Open "fileName.txt" For Input Access Read Shared As #1 Kevin Beckham -----Original Message----- I should add to this that I am actually importing a TXT file, so the code uses Workbooks.OpenText, not Workbooks.Open I see that if I use WorkBooks.Open, I can use ReadOnly:=True, however this doesn't work for Workbooks.OpenText -----Original Message----- I'm trying to get my macro to open a file as Readonly, but all I can do is get it to open a file. When I look at the code that is created for opening, opening as readonly and opening as copy, it all looks exactly the same. . . |
All times are GMT +1. The time now is 07:48 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com