Solved

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

Posted on 2003-11-17
7
530 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
  • 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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 50 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now