?
Solved

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

Posted on 2003-11-17
7
Medium Priority
?
548 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
Independent Software Vendors: 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

777 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