Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Check a file into SharePoint

I find a value for SaveFile as such:
SaveFile = Left(imgElement.Title, 27)

Then I get the path where this file needs to be saved, as such:
sPath = ThisWorkbook.Path & "/" & SaveFile

Then, I’m trying to check the file into SharePoint, which is something
like this:
Application.EnableEvents = False
wb.CheckIn True, "Update", True
Application.EnableEvents = True

…but it’s not working. Code fails on this line:
wb.CheckIn True, "Update", True

Error mssg is: ‘Run-time error 91. Object variable or With block
variable not set’

I have some sample code that works fine for opening a Template and
saving a (new) file to SharePoint (using a different technique):
sPath = strpath & "/" & striName & ".xls"
Dim sPathTemp As String
Set xlApp = New Excel.Application
xlApp.Visible = True
sPathTemp = strpath & "/" & "Template.xls"
Set wb = xlApp.Workbooks.Open(sPathTemp, , False)
xlApp.Workbooks("Template.xls").Worksheets("Sheet1 ").Range("D3") =
striName
xlApp.Workbooks.Application.CalculateFull
buildsavedest = ActiveWorkbook.Path & "/" & striName & ".xls"
xlApp.Workbooks("Template.xls").SaveAs buildsavedest

I also have code that checks a file into SharePoint; this works just
fine:
If ThisWorkbook.CanCheckIn = True Then
MsgBox "Saving Changes and Checking your File into SharePoint
now!!"
ThisWorkbook.Save
Application.EnableEvents = False
ThisWorkbook.CheckIn True, "Update", True
Application.EnableEvents = True
End If


All I need to do is save changes in an Excel file and check that file
into SharePoint:
File will be saved he
sPath = ThisWorkbook.Path & "/" & SaveFile

There must be some problem just before the code below, or in the code
below, that is not setting the (Worksheet) object:
Application.EnableEvents = False
wb.CheckIn True, "Update", True
Application.EnableEvents = True


Any ideas?

Thanks for the help!!
Ryan--


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Check a file into SharePoint

On Jul 22, 6:34*pm, ryguy7272 wrote:
I find a value for SaveFile as such:
SaveFile = Left(imgElement.Title, 27)

Then I get the path where this file needs to be saved, as such:
sPath = ThisWorkbook.Path & "/" & SaveFile

Then, I’m trying to check the file into SharePoint, which is something
like this:
Application.EnableEvents = False
wb.CheckIn True, "Update", True
Application.EnableEvents = True

…but it’s not working. *Code fails on this line:
wb.CheckIn True, "Update", True

Error mssg is: ‘Run-time error 91. Object variable or With block
variable not set’

I have some sample code that works fine for opening a Template and
saving a (new) file to SharePoint (using a different technique):
sPath = strpath & "/" & striName & ".xls"
Dim sPathTemp As String
Set xlApp = New Excel.Application
xlApp.Visible = True
sPathTemp = strpath & "/" & "Template.xls"
Set wb = xlApp.Workbooks.Open(sPathTemp, , False)
xlApp.Workbooks("Template.xls").Worksheets("Sheet1 ").Range("D3") =
striName
xlApp.Workbooks.Application.CalculateFull
buildsavedest = ActiveWorkbook.Path & "/" & striName & ".xls"
xlApp.Workbooks("Template.xls").SaveAs buildsavedest

I also have code that checks a file into SharePoint; this works just
fine:
If ThisWorkbook.CanCheckIn = True Then
* * MsgBox "Saving Changes and Checking your File into SharePoint
now!!"
* * ThisWorkbook.Save
* * Application.EnableEvents = False
* * ThisWorkbook.CheckIn True, "Update", True
* * Application.EnableEvents = True
End If

All I need to do is save changes in an Excel file and check that file
into SharePoint:
File will be saved he
sPath = ThisWorkbook.Path & "/" & SaveFile

There must be some problem just before the code below, or in the code
below, that is not setting the (Worksheet) object:
Application.EnableEvents = False
wb.CheckIn True, "Update", True
Application.EnableEvents = True

Any ideas?

Thanks for the help!!
Ryan--


Ok, so I (kind of) got this working and I wanted to share my code for
the benefit of others. This is how you 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???
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Check a file into SharePoint

On Jul 24, 5:27*pm, ryguy7272 wrote:
On Jul 22, 6:34*pm, ryguy7272 wrote:





I find a value for SaveFile as such:
SaveFile = Left(imgElement.Title, 27)


Then I get the path where this file needs to be saved, as such:
sPath = ThisWorkbook.Path & "/" & SaveFile


Then, I’m trying to check the file into SharePoint, which is something
like this:
Application.EnableEvents = False
wb.CheckIn True, "Update", True
Application.EnableEvents = True


…but it’s not working. *Code fails on this line:
wb.CheckIn True, "Update", True


Error mssg is: ‘Run-time error 91. Object variable or With block
variable not set’


I have some sample code that works fine for opening a Template and
saving a (new) file to SharePoint (using a different technique):
sPath = strpath & "/" & striName & ".xls"
Dim sPathTemp As String
Set xlApp = New Excel.Application
xlApp.Visible = True
sPathTemp = strpath & "/" & "Template.xls"
Set wb = xlApp.Workbooks.Open(sPathTemp, , False)
xlApp.Workbooks("Template.xls").Worksheets("Sheet1 ").Range("D3") =
striName
xlApp.Workbooks.Application.CalculateFull
buildsavedest = ActiveWorkbook.Path & "/" & striName & ".xls"
xlApp.Workbooks("Template.xls").SaveAs buildsavedest


I also have code that checks a file into SharePoint; this works just
fine:
If ThisWorkbook.CanCheckIn = True Then
* * MsgBox "Saving Changes and Checking your File into SharePoint
now!!"
* * ThisWorkbook.Save
* * Application.EnableEvents = False
* * ThisWorkbook.CheckIn True, "Update", True
* * Application.EnableEvents = True
End If


All I need to do is save changes in an Excel file and check that file
into SharePoint:
File will be saved he
sPath = ThisWorkbook.Path & "/" & SaveFile


There must be some problem just before the code below, or in the code
below, that is not setting the (Worksheet) object:
Application.EnableEvents = False
wb.CheckIn True, "Update", True
Application.EnableEvents = True


Any ideas?


Thanks for the help!!
Ryan--


Ok, so I (kind of) got this working and I wanted to share my code for
the benefit of others. *This is how you 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…
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check out Excel file from SharePoint; if no other Excel file is op RyGuy Excel Programming 0 May 21st 10 10:32 PM
Upload file to SharePoint from machine with CAC Richard Excel Programming 0 February 26th 10 02:30 PM
Sharepoint: How do I upload Excel (2003) Reports to Sharepoint? [email protected] Excel Programming 0 January 29th 09 11:34 AM
Excel links & SharePoint 3.0 (worked fine with SharePoint 2.0) ScottFisher2004 Excel Discussion (Misc queries) 0 November 10th 08 03:26 PM
Sharepoint File Dialog Mike Waldron[_3_] Excel Programming 0 July 9th 07 04:11 PM


All times are GMT +1. The time now is 08:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"