Solved

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

Posted on 2003-11-17
7
544 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
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!

 

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

Technology Partners: 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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

732 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