Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

excel automation

Status
Not open for further replies.

budz

Programmer
May 3, 2001
17
Hi guys, I have a problem in accessing my xls file with macro using vfp and im using the ff code:

oExcel = CreateObject('Excel.Application')
oWb = oExcel.Workbooks.open('c:\temp.xls')
oExcel.Application.visible = .t.
oExcel.DisplayAlerts = .t.

The problem is the xls file is always open read only. How can i open the xls file that is not read only so that i can save the changes in the same filename.

Thanks guys.
 

A quick look out on the MSDN yielded the following documentation for the open method of the workbooks collection:

expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMru, Local, CorruptLoad, OpenConflictDocument)

...so I would think that the 3rd parameter is of significance to you. Have you tried:

oWb = oExcel.Workbooks.open('c:\temp.xls',,.F.)

...also, have you checked the xls file that you are attempting to open to see whether or not it is marked with an Readonly attribute?

Slighthaze = NULL
[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
It could also be read only if it is in use by anyone.

Brian
 
If it is a small network, something may not have released the file. I recently had a client call me because their access database was read-only. I had them reboot and it solved it. I am not saying that is the problem, but if other solutions fail try our famous remedy reboot to see if that helps.

Jim Osieczonek
Delta Business Group, LLC
 
budz,

Any of these ideas work for you?

Slighthaze = NULL
[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
could also be that when testing your code you had an error in it causing you to hold on to the file and excel without you knowing

try pressing alt+ctrl+delete to see if you have excel running still

your help and advice is appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top