Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Excel File; CanCheckOut < True in SharePoint


Hello everyone. I’m using the following code to open an Excel file
from my SharePoint site.

If Workbooks.CanCheckOut(xlFile) = True Then
Application.EnableEvents = False
Workbooks.CheckOut xlFile
Application.EnableEvents = True
Application.StatusBar = "Opening file"
Set xlApp = New Excel.Application
xlApp.Visible = True
Set wb = xlApp.Workbooks.Open(xlFile, , False)
Application.StatusBar = ""
ThisWorkbook.Activate
Application.StatusBar = ""
End If

If the file is there, the code works fine. If the file is NOT there,
I get this message:
‘Run time error 1004’
Path . . . filename.xls could not be found. Check the spelling of the
name and verify that the location of the file is correct.

Well, I know the file is not there, so I certainly wouldn’t expect the
CanCheckOut status to be true, but how can I handle this error and
send the code to a sub named ‘CreateFile’ which can easily create the
file and name it and save it into SharePoint. The only problem is
that I don’t know how to handle this error. I tried some error
handling; got some ideas he
http://www.cpearson.com/excel/ErrorHandling.htm

However, I didn’t get anything working yet, and I don’t know if I
really want to be throwing errors anyway. Is there a more eloquent
way of handling this?

Thanks so much!!
Ryan---
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Excel File; CanCheckOut < True in SharePoint

On 20 Aug, 19:28, ryguy7272 wrote:
Hello everyone. *I’m using the following code to open an Excel file
from my SharePoint site.

* * If Workbooks.CanCheckOut(xlFile) = True Then
* * * * Application.EnableEvents = False
* * * * Workbooks.CheckOut xlFile
* * * * Application.EnableEvents = True
* * * * Application.StatusBar = "Opening file"
* * * * Set xlApp = New Excel.Application
* * * * xlApp.Visible = True
* * * * Set wb = xlApp.Workbooks.Open(xlFile, , False)
* * * * Application.StatusBar = ""
* * * * ThisWorkbook.Activate
* * * * Application.StatusBar = ""
* * End If

If the file is there, the code works fine. *If the file is NOT there,
I get this message:
‘Run time error 1004’
Path . . . filename.xls could not be found. Check the spelling of the
name and verify that the location of the file is correct.

Well, I know the file is not there, so I certainly wouldn’t expect the
CanCheckOut status to be true, but how can I handle this error and
send the code to a sub named ‘CreateFile’ which can easily create the
file and name it and save it into SharePoint. *The only problem is
that I don’t know how to handle this error. *I tried some error
handling; got some ideas hehttp://www.cpearson.com/excel/ErrorHandling..htm

However, I didn’t get anything working yet, and I don’t know if I
really want to be throwing errors anyway. *Is there a more eloquent
way of handling this?

Thanks so much!!
Ryan---


Sub SubName

On Error GoTo MissingFile
If Workbooks.CanCheckOut(xlFile) = True Then
Application.EnableEvents = False
Workbooks.CheckOut xlFile
Application.EnableEvents = True
Application.StatusBar = "Opening file"
Set xlApp = New Excel.Application
xlApp.Visible = True
Set wb = xlApp.Workbooks.Open(xlFile, , False)
Application.StatusBar = ""
ThisWorkbook.Activate
Application.StatusBar = ""
End If
On Error GoTo 0
Exit Sub

MissingFile:
Resume CreateNewFile
CreateNewFile:
On Error GoTo 0
Call CreateFile
end Sub
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
Using excel to Determine if a File Exists in SharePoint ryguy7272 Excel Programming 11 June 1st 10 09:34 PM
How to programmically upload Excel file to Sharepoint? Hii Sing Chung Excel Programming 4 September 17th 09 03:57 AM
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
Saving an XML file to a sharepoint location using VBA in excel [email protected] Excel Programming 1 May 14th 08 09:17 PM


All times are GMT +1. The time now is 08:50 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"