chris5000
07-02-2017, 03:54 AM
I have a workbook that we use to store data everytime we go out in the field. The code was running perfect when I was running and saving it from my desktop. When I put the file on a shared drive and ran through the macro, I get this run-time error everytime it attempts to save. Does anyone have any idea why?
The error message is:
"Run-time error '1004':
We can't save 'M:Services\walklog\v3-current-testing.xlsm' because the file is read only.
To keep your changes, you'll need to save the workbook with a new name or in a different location."
I'm pretty sure the file is not read-only because I unticked the "read-only" box in the properties tab. I also tried to save the workbook with a different name and in a different location but it still didn't work.
When I hit debug, the ActiveWorkbook.Save line is highlighted. Pleasae see code below.
Sub findIndexes(export1 As ExportSet)
Dim lastRowIndex As Integer
Dim firstRowIndex As Integer
Dim lastRowString As String
Dim firstRowString As String
ActiveWorkbook.Save
lastRowIndex = Sheets("LOG").Cells(Sheets("LOG").Rows.Count, "C").End(xlUp).Row
'firstRowIndex = Sheets("LOG").Cells(Sheets("LOG").Rows.Count, "D").End(xlUp).Row
lastRowString = "a2:n" & lastRowIndex
'firstRowString = "a2:n" & firstRowIndex
'export1.firstRow = firstRowString
export1.lastrow = lastRowString
MsgBox "" & export1.lastrow
End Sub
Would be good to get some feedback. Thanks in advance.
The error message is:
"Run-time error '1004':
We can't save 'M:Services\walklog\v3-current-testing.xlsm' because the file is read only.
To keep your changes, you'll need to save the workbook with a new name or in a different location."
I'm pretty sure the file is not read-only because I unticked the "read-only" box in the properties tab. I also tried to save the workbook with a different name and in a different location but it still didn't work.
When I hit debug, the ActiveWorkbook.Save line is highlighted. Pleasae see code below.
Sub findIndexes(export1 As ExportSet)
Dim lastRowIndex As Integer
Dim firstRowIndex As Integer
Dim lastRowString As String
Dim firstRowString As String
ActiveWorkbook.Save
lastRowIndex = Sheets("LOG").Cells(Sheets("LOG").Rows.Count, "C").End(xlUp).Row
'firstRowIndex = Sheets("LOG").Cells(Sheets("LOG").Rows.Count, "D").End(xlUp).Row
lastRowString = "a2:n" & lastRowIndex
'firstRowString = "a2:n" & firstRowIndex
'export1.firstRow = firstRowString
export1.lastrow = lastRowString
MsgBox "" & export1.lastrow
End Sub
Would be good to get some feedback. Thanks in advance.