Opening Excel file read/write

  • Thread starter Thread starter wmdmurphy
  • Start date Start date
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
 
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?
 
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?
 
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
 
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
 
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
 
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
 
Back
Top