?
Solved

How could I open an existing Excel file and set attribute Read only

Posted on 2003-11-17
7
Medium Priority
?
550 Views
Last Modified: 2007-12-19
I use BCB and OLE object "Excel.Application" to open an existing Excel file.
Could I open this existing excel file and set it to be read only through OleProcedure or OleFunction directly?
By the moment, my code is:   Workbook=Workbooks.OleFunction("open", "c:\\test.xls");
it will open an Existing file and could modify data.
I know FileSetAttr Function may make it? But I hope open an file by OleProcedure and set it ReadOnly directly..
0
Comment
Question by:abdate
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 16

Expert Comment

by:George Tokas
ID: 9762923
There is no need to do it through OLE.
You can use "FileSetAttr".
extern PACKAGE int __fastcall FileSetAttr(const AnsiString FileName, int Attr);
Internal help will guide you.

gtokas.
0
 

Author Comment

by:abdate
ID: 9765659
Thank you! I know FileSetAttr may do it just I mentioned before. But I wonder Does OLE procedure can do it only change some parameter? If so, I don't need to use FileSetAttr.
0
 
LVL 16

Expert Comment

by:George Tokas
ID: 9770068
My opinion is that when you can use native borland calls it is better to do it that way...
Right now I'm working with OLE with Internet explorer and its hell to try 2 find my way due 2 error messages when I link Microsoft's headers.

gtokas.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:abdate
ID: 9770117
I read MSDN for opening Excel like the following paragraph:
Sub OpenUp()
    Workbooks.Open("C:\MyFolder\MyBook.xls")
End Sub
and
expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMRU)
How do write in BCB

Regards
abday
0
 
LVL 16

Accepted Solution

by:
George Tokas earned 200 total points
ID: 9770382
Suppose you have pro or enterprise version >= 5 of BCB.
At the servers page of objects there is ExcelAplication.
The help file (must download as office97 help file) gives explaination on how it is wrapped and how you can work with them...
It will be better if you use the VCL rather than MFC.
To tell the truth for myself I didn't find a way myself YET but I hope in a few days I will.

gtokas.
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10249262
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: gtokas {http:#9770382}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question