Check an a file; SharePoint

R

ryguy7272

I’m following the example here:
http://msdn.microsoft.com/en-us/library/aa223808(office.11).aspx

Here’s my code:
' Determine if workbook can be checked in.
If Workbooks(SaveFile).CanCheckIn = True Then
Workbooks(SaveFile).CheckIn
MsgBox SaveFile & " has been checked in."
Else
MsgBox "This file cannot be checked in " & _
"at this time. Please try again later."
End If

‘SaveFile’ is dimmed as a string; it is the name of my Excel file,
which comes from here:
SaveFile = Left(imgElement.Title, 27)

I mouse-over the variable and see that the value is correct, but the
code fails on this line:
If Workbooks(SaveFile).CanCheckIn = True Then

SaveFile is checked out from SharePoint. How come I can’t check it
in? Do I need to fully qualify SaveFile with the path to SharePoint
so Excel knows WHERE to check the file in?

I’d appreciate any ideas with this.

Thanks!!
Ryan---
 
R

ryguy7272

I’m following the example here:http://msdn.microsoft.com/en-us/library/aa223808(office.11).aspx

Here’s my code:
' Determine if workbook can be checked in.
If Workbooks(SaveFile).CanCheckIn = True Then
Workbooks(SaveFile).CheckIn
MsgBox SaveFile & " has been checked in."
Else
MsgBox "This file cannot be checked in " & _
"at this time.  Please try again later."
End If

‘SaveFile’ is dimmed as a string; it is the name of my Excel file,
which comes from here:
SaveFile = Left(imgElement.Title, 27)

I mouse-over the variable and see that the value is correct, but the
code fails on this line:
If Workbooks(SaveFile).CanCheckIn = True Then

SaveFile is checked out from SharePoint.  How come I can’t check it
in?  Do I need to fully qualify SaveFile with the path to SharePoint
so Excel knows WHERE to check the file in?

I’d appreciate any ideas with this.

Thanks!!
Ryan---

Ok, so I (kind of) got this working and I wanted to share my code for
the benefit of others. This will save a file to SharePoint:
sPath = strpath & "/" & SaveFile
Dim sPathTemp As String
Set xlApp = New Excel.Application
xlApp.Visible = True
Set WB = xlApp.Workbooks.Open(sPath, , False)
xlApp.Workbooks.Application.CalculateFull
Application.DisplayAlerts = False
buildsavedest = sPath
xlApp.Workbooks(SaveFile).SaveAs buildsavedest
Application.DisplayAlerts = True

SaveFile is parsed, as such:
SaveFile = Left(imgElement.Title, 27)

That's simply the file that I'm saving.

The only thing that's I'm struggling with now is to be able to undo
the CheckOut Property (or set the CheckIn Property). Does anyone know
how to do this???
 
R

ryguy7272

Ok, so I (kind of) got this working and I wanted to share my code for
the benefit of others.  This will save a file to SharePoint:
sPath = strpath & "/" & SaveFile
Dim sPathTemp As String
Set xlApp = New Excel.Application
xlApp.Visible = True
Set WB = xlApp.Workbooks.Open(sPath, , False)
xlApp.Workbooks.Application.CalculateFull
Application.DisplayAlerts = False
buildsavedest = sPath
xlApp.Workbooks(SaveFile).SaveAs buildsavedest
Application.DisplayAlerts = True

SaveFile is parsed, as such:
SaveFile = Left(imgElement.Title, 27)

That's simply the file that I'm saving.

The only thing that's I'm struggling with now is to be able to undo
the CheckOut Property (or set the CheckIn Property).  Does anyone know
how to do this???- Hide quoted text -

- Show quoted text -


As it turns out, this seems to do the trick:
xlApp.Workbooks(SaveFile).SaveAs buildsavedest
xlApp.Workbooks(SaveFile).CheckIn SaveChanges:=True, _
Comments:=""

Hope this helps others…
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top