Opening Excel file read/write

W

wmdmurphy

I have an app where I want the user to be able to click a command button and
open a selected Excel workbook read/write. So far Excel is only opening up
read only. Here's the code I'm using:

If Not ExcelRunning Then
Set objExcel = New Excel.Application
Else
Set objExcel = GetObject(, "Excel.Application")
End If

objExcel.Visible = True

objExcel.Workbooks.Open FileName:=strFullPathAndName, ReadOnly:=False

I thought the ReadOnly:=False would make the workbook writeable, but that's
not happening. I've also tried FollowHyperlink with the same result.

Any thoughts will be appreciated.

Bill
 
A

Arvin Meyer MVP

First, check the file attributes of the file you are attempting to open.
Then check to see if protection has been applied.

Have you tried opening a new blank workbook that's been previously saved?
 
A

Arvin Meyer MVP

First, check the file attributes of the file you are attempting to open.
Then check to see if protection has been applied.

Have you tried opening a new blank workbook that's been previously saved?
 
K

kc-mass

Try this slight variation on your code. It opens the file with full write
options.
Sub OpenExcel()
Dim strFullPathAndName As String
strFullPathAndName = "c:\BoatStorageCost.xls"
If Not ExcelRunning Then
Set objExcel = CreateObject("Excel.Application")
Else
Set objExcel = GetObject(, "Excel.Application")
End If
objExcel.Visible = True
objExcel.Workbooks.Open FileName:=strFullPathAndName, ReadOnly:=False
End Sub
 
K

kc-mass

Try this slight variation on your code. It opens the file with full write
options.
Sub OpenExcel()
Dim strFullPathAndName As String
strFullPathAndName = "c:\BoatStorageCost.xls"
If Not ExcelRunning Then
Set objExcel = CreateObject("Excel.Application")
Else
Set objExcel = GetObject(, "Excel.Application")
End If
objExcel.Visible = True
objExcel.Workbooks.Open FileName:=strFullPathAndName, ReadOnly:=False
End Sub
 
W

wmdmurphy

Arvin and KC,

I believe Arvin is right, that the problem is that the file or folder is set to read only. I think I've been bitten by the Microsoft XP "feature", where all folders are set to read only, and you can't change them to read/write. I've tried this with a new test folder and when created it is also set to read only, and not changeable. The Excel file I'm opening is not set to read only, just the folder it's in.

Microsoft has a "fix" in article 326549, which I found does not work. They propose changing the attributes of the folder from the command prompt with this code:

attrib -r +s c:\test

I've also found one proposed registry change on a web site, inserting and setting UseSystemFprSystemFolders = 1, but I'm hesitating to make this change.

Have you run into this problem in the past?

Bill
 
W

wmdmurphy

Arvin and KC,

I believe Arvin is right, that the problem is that the file or folder is set to read only. I think I've been bitten by the Microsoft XP "feature", where all folders are set to read only, and you can't change them to read/write. I've tried this with a new test folder and when created it is also set to read only, and not changeable. The Excel file I'm opening is not set to read only, just the folder it's in.

Microsoft has a "fix" in article 326549, which I found does not work. They propose changing the attributes of the folder from the command prompt with this code:

attrib -r +s c:\test

I've also found one proposed registry change on a web site, inserting and setting UseSystemFprSystemFolders = 1, but I'm hesitating to make this change.

Have you run into this problem in the past?

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top