How do I stop a macro keep repeating its self.

ghrek

Active Member
Joined
Jul 29, 2005
Messages
426
I have this code in the area called "this workbook"


VBA Code:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)

Call Macro1
End Sub



And this is macro 1

VBA Code:
 ActiveWorkbook.SaveAs Filename:= _
"https://xxrivagroup.sharepoint.com/teams/PASSACC/Shared%20Documents/General/shrek%20summary.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
ActiveWorkbook.Save
    ActiveWorkbook.Close



The issue I have now is that the macro keeps on repeating its self and saving all the time and the only way out is to push esc key. Is there anyway round this?

Thanks
 
I have not worked with Sharepoint at all, so I cannot really over any advice on that.
I would recommend starting a new thread on that, since it is a new question.
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
You might want to specify where you are starting from. That is, are you updating the file while on the sharepoint server, then saving the remote file before saving the local file. You might need to include a ChDir command in your code to bring the active directory back to your system, or use the full name (including path) for each save action. That was not made clear in this thread.
 
Upvote 0
You might want to specify where you are starting from. That is, are you updating the file while on the sharepoint server, then saving the remote file before saving the local file. You might need to include a ChDir command in your code to bring the active directory back to your system, or use the full name (including path) for each save action. That was not made clear in this thread.


Apologies. In response to comments

I explain on what I’m trying to do that may be easier as a novice.

I have the document on a local file and when I save it creates a sharepoint file with same name and saves there as well as saving locally.

That bit I have in the macro already and is fine.

What I’m then trying to do is after I have added data to the local file after originally saving and reopening later I need it to again save locally and to sharepoint but NOT create a new file in sharepoint but overwrite the existing file that is there.

Doesn’t matter which way round it saves it sharepoint first then locally or VV as along as saved to both.

As far as your remarks about Chrdir yes I know it means chain directory but what it does or where it goes into got a clue.

Hope that helps
 
Upvote 0
Then you should be able to open your local file, make your changes and do a normal save. Then do a SaveAs using the path to the share drive file and when you get the "File Name Already Exists" message, just answer it with yes to overwrite the share drive version.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,243
Members
449,075
Latest member
staticfluids

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