+ Reply to Thread
Results 1 to 2 of 2

Macro to overwrite master for changes made in master and read only

  1. #1
    Registered User
    Join Date
    03-22-2013
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2007
    Posts
    2

    Macro to overwrite master for changes made in master and read only

    Hello,
    I am new to the fourm and a novice when it comes to VBA coding. I created this spreadsheet at work to tally hyperlink counts to track how much of are our associates are using each link. The workbook is protected and is not shared, for integrity of the information in each cell.

    I currently have a macro in place to auto save the workbook upon close and to ignore any changes made if the file is ready only (temporary). If one associate is on the master file all day, when other assoicate access the file it is forced to be opened as read only. Therefore any hyperlink that are click in the read only file are not tracked and are giving me scewed figures.

    Sub Auto_Close()
    If ThisWorkbook.Readonly Then
    ThisWorkbook.Saved = True
    End If
    If ThisWorkbook.Saved = False Then
    ThisWorkbook.Save
    End If

    End Sub

    Is there an auto close macro to save changes made to the master and read only version and overwrite the master file on our share drive? Any suggestion or comments will be greatly appreciated!

  2. #2
    Registered User
    Join Date
    03-22-2013
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Macro to overwrite master for changes made in master and read only

    I have try messing with this coding and when I'm in the master file the coding works fine. Problem arises when I am in the read only file. I am receiving Run-Time Error '1004'

    "Cannot save as that name. Document was opened as read-only. This is the coding I have so far to save the changes for both the read only and the master file to overwrite the master on our share drive.

    Sub Auto_Close()
    If ThisWorkbook.Readonly Then
    Dim sName As String
    ActiveWorkbook.SaveAs Filename:="U:\CostBasis\GK Test\Fixes\Spreadsheet\Master\Answer.xlsm", _
    ReadOnlyRecommended:=False
    sName = ActiveWorkbook.FullName
    ActiveWorkbook.Close SaveChanges:=True
    SetAttr sName, 1
    End If
    If ThisWorkbook.Saved = False Then
    ThisWorkbook.Save
    End If

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1