Save a file to SharePoint

R

ryguy7272

I know this code was working yesterday; today it is NOT working:

SaveFile comes from parsing a string, as such:
SaveFile = Left(imgElement.Title, 27)

Here’s the code that I was using to save a file to SharePoint, and
make the status of the file NOT checkedout.

Dim bk As Workbook
Dim APP As Excel.Application
Dim obj
Set bk = Workbooks(SaveFile)
Set APP = bk.Parent
APP.Workbooks(SaveFile).CheckIn
bk.Activate
bk.CheckIn
Workbooks(SaveFile).Activate
Workbooks(SaveFile).Save
Workbooks(SaveFile).CheckIn
bk.undocheckout

It seems to be very simple to check in ThisWorkbook, but very
difficult to checkin another file that is NOT ThisWorkbook.

Any ideas on how to do this?

As always, thanks!
 
R

ryguy7272

I know this code was working yesterday; today it is NOT working:

SaveFile comes from parsing a string, as such:
SaveFile = Left(imgElement.Title, 27)

Here’s the code that I was using to save a file to SharePoint, and
make the status of the file NOT checkedout.

Dim bk As Workbook
Dim APP As Excel.Application
Dim obj
Set bk = Workbooks(SaveFile)
Set APP = bk.Parent
APP.Workbooks(SaveFile).CheckIn
bk.Activate
bk.CheckIn
Workbooks(SaveFile).Activate
Workbooks(SaveFile).Save
Workbooks(SaveFile).CheckIn
bk.undocheckout

It seems to be very simple to check in ThisWorkbook, but very
difficult to checkin another file that is NOT ThisWorkbook.

Any ideas on how to do this?

As always, thanks!


Ok, so I actually got this working and I wanted to share my code for
the benefit of others:
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 knwo
how to do this???
 
R

ryguy7272

Ok, so I actually got this working and I wanted to share my code for
the benefit of others:
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 knwo
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…
 
R

ryguy7272

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…


Got it working!! I had some help from a colleague in my office.
Thanks Mandeep!!
 

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