VBA Track changes on shared workbook

Michiko

New Member
Joined
Oct 21, 2015
Messages
9
Hello Everyone,

I have a VBA that copies a given sheet from my workbook.xlsm to a new workbook.xlsx and saves it in a shared folder. It works just fine, but I want it to enable track changes on the new workbook.xlsx before closing it.

Since I'm not an expert on code, nor whatsoever!, I've just searched for the piece of code online. However, I've already tried a lot of combinations and none worked, I always get an error. Currently, I'm using this:

VBA Code:
With ActiveWorkbook
  .HighlightChangesOptions _
  When:=xlAllChanges, _
  Who:="Everyone"
  .ListChangesOnNewSheet = False
  .HighlightChangesOnScreen = True
End With

And getting this:

1629970390933.png


(Yes... The code gets highlighted... Just not the kind of highlight I want ?)

Can anyone help, please?

Thanks!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Also: if I just save the workbook.xlsx and open it, I can see that the 'Track Changes (Legacy)' feature isn't available:

1629973046253.png


I think it might be the reason, but I don't know how to make it available before enabling it (through the VBA code).
 
Upvote 0
Changes can only be tracked in shared workbooks. This is an Excel feature and is not the same as a shared folder on disk.
At the point a workbook's access mode is changed to shared (as opposed to the default, which is exclusive) the workbook has to be saved again in order to make it actually effective.
So after saving the new workbook in the shared folder you should be able to change its access mode and also keep track of changes other users make to the workbook. Your code could look like below and you might consider to take a look over here ...


VBA Code:
Sub Michiko()

    Const NEWFILE As String = "Z:\Users\SharedFolder\YourWorkbook.xlsx"         ' <<< change file name to suit

    Dim wbNew   As Workbook

    ThisWorkbook.Sheets("Sheet1").Copy                                          ' <<< change sheet name to suit
    Set wbNew = ActiveWorkbook

    With wbNew
        .SaveAs Filename:=NEWFILE, FileFormat:=xlOpenXMLWorkbook, AccessMode:=xlShared

        .KeepChangeHistory = True
        .HighlightChangesOptions When:=xlAllChanges, Who:="Everyone"
        .ListChangesOnNewSheet = False
        .HighlightChangesOnScreen = True
        .Save
        .Close
    End With
End Sub
 
Upvote 0
@GWteB Thank you very much for your help. However, it's still not working.

Actually, I already had the AccessMode:=xlShared embedded on the code when saving the sheet as a new workbook.

Any other idea?
 
Upvote 0
Please elaborate on "it's still not working". Any warning or error message and if so, on which line within the code does that occur?
Additional questions are: Is that particular worksheet protected? Does its code-behind module contain any code?
 
Upvote 0
I get the exact same error I did. All .saveas syntax gets highlighted.

VBA Code:
    With wbNew
        .SaveAs Filename:= _
        "https://company.sharepoint.com/sites/Company/Shared%20Documents/OPS%20Activity%20Report.xlsx" _
        , FileFormat:=xlOpenXMLWorkbook, AccessMode:=xlShared

        .KeepChangeHistory = True
        .HighlightChangesOptions When:=xlAllChanges, Who:="Everyone"
        .ListChangesOnNewSheet = False
        .HighlightChangesOnScreen = True
        .Save
        .Close
    End With

And no, the worksheet isn't protected.
 
Upvote 0
Try converting the url to a proper path, like:

VBA Code:
"\\company.sharepoint.com\sites\Company\Shared Documents\OPS Activity Report.xlsx"
 
Upvote 0
I have a VBA that copies a given sheet from my workbook.xlsm to a new workbook.xlsx and saves it in a shared folder. It works just fine, but ....
Seems you are talking about different issues here :unsure:
 
Upvote 0
Still getting exactly the same error and part of the code highlighted.

If I remove AccessMode:=xlShared it only stumbles on .HighlightChangesOptions When:=xlAllChanges, Who:="Everyone"
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top