Checking out SharePoint document via macro

Analyze_This

Board Regular
Joined
Oct 29, 2008
Messages
122
Good afternoon everyone,
I'm trying to write a macro to open a workbook in SharePoint, check it out, do my thing (technical term), and then check in/close the workbook. I've managed to get the book open, but I get an error when trying to check out or check in. Any thoughts? Here is the code I'm using:

Sub WorkDamnit()

Workbooks.Open Filename:= _
"http://xxxxxxxxx.xlsx"

'THIS IS SUPPOSED TO CHECK OUT, BUT GIVES ERROR
ExecuteExcel4Macro _
"(""http://xxxxxxxxx.xlsx"",48)"

'HERE IS MY CODE


'SUPPOSED TO CHECK IN, BUT GIVES ERROR
ExecuteExcel4Macro _
"(TRUE,"""",FALSE,0,""http://xxxxxxx.xlsx"",0,0)"

End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Good afternoon everyone,
I'm trying to write a macro to open a workbook in SharePoint, check it out, do my thing (technical term), and then check in/close the workbook. I've managed to get the book open, but I get an error when trying to check out or check in. Any thoughts? Here is the code I'm using:

Sub Work****it()

Workbooks.Open Filename:= _
"http://xxxxxxxxx.xlsx"

'THIS IS SUPPOSED TO CHECK OUT, BUT GIVES ERROR
ExecuteExcel4Macro _
"(""http://xxxxxxxxx.xlsx"",48)"



'HERE IS MY CODE


'SUPPOSED TO CHECK IN, BUT GIVES ERROR
ExecuteExcel4Macro _
"(TRUE,"""",FALSE,0,""http://xxxxxxx.xlsx"",0,0)"

End Sub

--

Yep, this is what you get when you record the check out/check in process. VBA does give you the commands to do this, although in my experience it only works if you check the file out, then open it, then close it, then check it in:


Sub CheckOut()

Dim FileName As String

Workbooks(FileName).CheckOut
WorkBooks(FileName).Open

'Code here

ActiveWorkBook.Close

End Sub


As a default you will now get the normal 'Do you want to save changes?' and 'Do you want to check in now?' prompts, but you can manipulate these via VBA if you want.

HTH

MJ
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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