PDA

View Full Version : Run-time error '1004' when saving spreadsheet



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.

mdmackillop
07-02-2017, 04:52 AM
Your Save appears to be in a Sub called by another routine so we don't know what else is going on. Try moving it to the main sub to run when all code execution is complete.
What is ExportSet?