View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272[_2_] ryguy7272[_2_] is offline
external usenet poster
 
Posts: 56
Default Save a file to SharePoint

On Jul 24, 3:34*pm, ryguy7272 wrote:
On Jul 24, 5:23*pm, ryguy7272 wrote:



On Jul 24, 2:48*pm, ryguy7272 wrote:


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???- 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…



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