Consulting

Results 1 to 2 of 2

Thread: Run-time error '1004' when saving spreadsheet

  1. #1

    Run-time error '1004' when saving spreadsheet

    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.
    Last edited by mdmackillop; 07-02-2017 at 04:53 AM. Reason: Code tags added

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •