CheckIn SharePoint Excel file fail

ddander54

Board Regular
Joined
Oct 18, 2012
Messages
97
This code works perfectly for me to check if the file can be checked out. The problem is the CheckIn part....I'm getting an error: Method or Data Member not found and CanCheckIn is highlighted. I have tried substituting the FileName for the docCheckIn variable as suggested below without any luck as well. Any help would be appreciated.

VBA Code:
Option Explicit

'https://stackoverflow.com/questions/51606517/how-to-check-in-a-file-on-sharepoint
'https://stackoverflow.com/questions/55120943/sharepoint-checkin-file-method-or-data-member-not-found
  'Set WbObj = Workbooks("workbookname.xls") 'if it's open
  'Set WbObj = Workbooks.Open(docCheckIn)    'if it isn't open
  'edit: Workbooks(docCheckIn).CanCheckIn will work but the docCheckIn must be a workbook name, not full path. Alternatively set the workbook as object using your docCheckIn path and use WbObj.CanCheckIn
  'edit2: bear in mind that the Workbooks.checkin docCheckIn will have to be changed the same way to either Workbooks("workbookname.xls").checkin or WbObj.checkin

Sub SharePointCheckOutIn()
    Dim docCheckOut As String
    Dim docCheckIn As String
    'docCheckIn = "WorkMix_Re-Forecast_2022.xlsx"
    docCheckOut = "http://kb/sites/PMO/Metrics and Reporting/2022 Financials/WorkMix_Re-Forecast_2022.xlsx"
    Call UseCheckOut(docCheckOut)
    Call UseCheckIn(docCheckIn)
End Sub

Sub UseCheckOut(docCheckOut As String)
     ' Determine if workbook can be checked out.
    If Workbooks.CanCheckOut(docCheckOut) = True Then
        Workbooks.CheckOut docCheckOut
    Else
        MsgBox "Unable to check out this document at this time."
    End If
End Sub

Sub UseCheckIn(docCheckIn As String)
    docCheckIn = "WorkMix_Re-Forecast_2022.xlsx"
     ' Determine if workbook can be checked in.
    If Workbooks.CanCheckIn(docCheckIn) = True Then  '<<<<Method or Data Member Not Found and CanCheckIn is highlighted
        Workbooks.CheckIn docCheckIn
    Else
        MsgBox "Unable to check in this document at this time."
    End If
End Sub


Thanks in Advance,
Don
 
Look at the code posted here and note that it was suggested using the syntax you had. Unfortunately, there was no followup to advise whether or not it worked. Note that it is reversed from the link I gave you in post 6 - did you check that out? I may have to go looking for the file where I used this feature, depending on answers to post 10.
 
Upvote 0
Solution

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Is all of this code in the same worksheet module, or have you cobbled it together from other places?

EDIT - The workbook does exist, yes? And the path is correct?
Micron,

Currently it is all 1 module in my Personal Workbook that I got from these 2 sources. The workbook does exist and does CheckOut with the first part of the module UseCheckOut when I uncomment the Call statement.
'How to check-in a file on sharepoint?
'SharePoint Checkin file - Method or data member not found

Don
 
Upvote 0
Look at the code posted here and note that it was suggested using the syntax you had. Unfortunately, there was no followup to advise whether or not it worked. Note that it is reversed from the link I gave you in post 6 - did you check that out? I may have to go looking for the file where I used this feature, depending on answers to post 10.
Micron,

In Reference to your post #11. I was able to get that code to work. One thing that I noticed while testing it is that the file opens up 'behind' another Excel file that was already open. If I left the file back there and run the checkin code without the EntireColumn AutoFit line, it failed, if I selected the file file (brought it forward) and then again without the EntireColumn AutoFit line, it worked. It ran as is when the EntireColumn AutoFit line was enabled.



Don
 
Upvote 0
If you're saying your original method had 2 wb's open that sounds like error 9 was due to the wrong wb being the active one but not sure. BTW, I looked in my old project and the syntax was
Workbooks.CanCheckOut(svChartPath)

which is not what M$ documentation shows.
You're saying all is good now?
 
Upvote 0
If you're saying your original method had 2 wb's open that sounds like error 9 was due to the wrong wb being the active one but not sure. BTW, I looked in my old project and the syntax was
Workbooks.CanCheckOut(svChartPath)

which is not what M$ documentation shows.
You're saying all is good now?
Micron,

The code in Post #11 is different code that what we have been working on, but yes I did get that code to work. The original code that we have working with (which was marked as a solution in another forum) still doesn't work. I will mark Post #11 as a solution and I thank you for your time and help....much appreciated.

Don
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

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