Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default How to programmically upload Excel file to Sharepoint?

I would like to have VBA to automatically/programmically upload an Excel
file to a Sharepoint site. I tried the code below but got 'File not Found'
error. I could manually save as the file to the same path, so the path is
correct. Any suggestions?
Sub PostToSharepoint()
Dim wbBook As Workbook
Dim wsSheet As Worksheet
Dim strWorkSheet As String
Dim cell As Range
Dim strFileName
strWorkSheet = Format(Date - 1, "mmmmyy")
Set wbBook = ThisWorkbook
Set wsSheet = ThisWorkbook.Sheets(strWorkSheet)
wsSheet.Activate
strFileName = "http://myweb:8585/sites/it_security/monitoring/Shared
Documents/Management Reports/Daily Reports.xls"
For Each cell In Range(Range("B4"), Range("B34"))
If cell.Value <= Now() - 1 And IsFormula(cell.Offset(0, 1)) =
True Then
cell.Range(cell.Offset(0, 1), cell.Offset(0, 4)).Copy
Range(cell.Offset(0, 1), cell.Offset(0, 4)).PasteSpecial
(xlPasteValues)
End If
Next cell
ThisWorkbook.SaveCopyAs Filename:=strFileName 'File not found error
occurred'
End Sub
Function IsFormula(Check_Cell As Range)
IsFormula = Check_Cell.HasFormula
End Function


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default How to programmically upload Excel file to Sharepoint?

try changing the file name. Your code uses this variable strFileName , which
is the file that you opened. try
ThisWorkbook.SaveCopyAs "Test"

and see where it gest saved to

"Hii Sing Chung" wrote:

I would like to have VBA to automatically/programmically upload an Excel
file to a Sharepoint site. I tried the code below but got 'File not Found'
error. I could manually save as the file to the same path, so the path is
correct. Any suggestions?
Sub PostToSharepoint()
Dim wbBook As Workbook
Dim wsSheet As Worksheet
Dim strWorkSheet As String
Dim cell As Range
Dim strFileName
strWorkSheet = Format(Date - 1, "mmmmyy")
Set wbBook = ThisWorkbook
Set wsSheet = ThisWorkbook.Sheets(strWorkSheet)
wsSheet.Activate
strFileName = "http://myweb:8585/sites/it_security/monitoring/Shared
Documents/Management Reports/Daily Reports.xls"
For Each cell In Range(Range("B4"), Range("B34"))
If cell.Value <= Now() - 1 And IsFormula(cell.Offset(0, 1)) =
True Then
cell.Range(cell.Offset(0, 1), cell.Offset(0, 4)).Copy
Range(cell.Offset(0, 1), cell.Offset(0, 4)).PasteSpecial
(xlPasteValues)
End If
Next cell
ThisWorkbook.SaveCopyAs Filename:=strFileName 'File not found error
occurred'
End Sub
Function IsFormula(Check_Cell As Range)
IsFormula = Check_Cell.HasFormula
End Function



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default How to programmically upload Excel file to Sharepoint?

Dear Patrick,

I already assigned the variable strFileName to
""http://myweb:8585/sites/it_security/monitoring/Shared Documents/Management
Reports/Daily Reports.xls". If I use "test" it will work. It failed because
it is not a filesystem path, it is an http path, so my question is how to
tell Excel to use http as path or something like that. Alternatively, is
there a way to get around this limitation so that I can met my requirement
of uploading file to a Sharepoint site automatically.

"Patrick Molloy" wrote in message
...
try changing the file name. Your code uses this variable strFileName ,
which
is the file that you opened. try
ThisWorkbook.SaveCopyAs "Test"

and see where it gest saved to

"Hii Sing Chung" wrote:

I would like to have VBA to automatically/programmically upload an Excel
file to a Sharepoint site. I tried the code below but got 'File not
Found'
error. I could manually save as the file to the same path, so the path is
correct. Any suggestions?
Sub PostToSharepoint()
Dim wbBook As Workbook
Dim wsSheet As Worksheet
Dim strWorkSheet As String
Dim cell As Range
Dim strFileName
strWorkSheet = Format(Date - 1, "mmmmyy")
Set wbBook = ThisWorkbook
Set wsSheet = ThisWorkbook.Sheets(strWorkSheet)
wsSheet.Activate
strFileName =
"http://myweb:8585/sites/it_security/monitoring/Shared
Documents/Management Reports/Daily Reports.xls"
For Each cell In Range(Range("B4"), Range("B34"))
If cell.Value <= Now() - 1 And IsFormula(cell.Offset(0, 1)) =
True Then
cell.Range(cell.Offset(0, 1), cell.Offset(0, 4)).Copy
Range(cell.Offset(0, 1), cell.Offset(0, 4)).PasteSpecial
(xlPasteValues)
End If
Next cell
ThisWorkbook.SaveCopyAs Filename:=strFileName 'File not found
error
occurred'
End Sub
Function IsFormula(Check_Cell As Range)
IsFormula = Check_Cell.HasFormula
End Function



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default How to programmically upload Excel file to Sharepoint?

I've mapped sharepoint drives that I access frequently to an available drive
letter.. I've found that I need to make sure that the WebClient service is
running to be able to access it that way though.

HTH,
Barb Reinhardt

"Hii Sing Chung" wrote:

Dear Patrick,

I already assigned the variable strFileName to
""http://myweb:8585/sites/it_security/monitoring/Shared Documents/Management
Reports/Daily Reports.xls". If I use "test" it will work. It failed because
it is not a filesystem path, it is an http path, so my question is how to
tell Excel to use http as path or something like that. Alternatively, is
there a way to get around this limitation so that I can met my requirement
of uploading file to a Sharepoint site automatically.

"Patrick Molloy" wrote in message
...
try changing the file name. Your code uses this variable strFileName ,
which
is the file that you opened. try
ThisWorkbook.SaveCopyAs "Test"

and see where it gest saved to

"Hii Sing Chung" wrote:

I would like to have VBA to automatically/programmically upload an Excel
file to a Sharepoint site. I tried the code below but got 'File not
Found'
error. I could manually save as the file to the same path, so the path is
correct. Any suggestions?
Sub PostToSharepoint()
Dim wbBook As Workbook
Dim wsSheet As Worksheet
Dim strWorkSheet As String
Dim cell As Range
Dim strFileName
strWorkSheet = Format(Date - 1, "mmmmyy")
Set wbBook = ThisWorkbook
Set wsSheet = ThisWorkbook.Sheets(strWorkSheet)
wsSheet.Activate
strFileName =
"http://myweb:8585/sites/it_security/monitoring/Shared
Documents/Management Reports/Daily Reports.xls"
For Each cell In Range(Range("B4"), Range("B34"))
If cell.Value <= Now() - 1 And IsFormula(cell.Offset(0, 1)) =
True Then
cell.Range(cell.Offset(0, 1), cell.Offset(0, 4)).Copy
Range(cell.Offset(0, 1), cell.Offset(0, 4)).PasteSpecial
(xlPasteValues)
End If
Next cell
ThisWorkbook.SaveCopyAs Filename:=strFileName 'File not found
error
occurred'
End Sub
Function IsFormula(Check_Cell As Range)
IsFormula = Check_Cell.HasFormula
End Function



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default How to programmically upload Excel file to Sharepoint?

Dear Barb,

The mapping of drive to Sharepoint is not possible in our environment. If
not, it will be easy to accomplish. I have to workaround this restriction.
Network folder and file sharing is 'locked-down' in our environment. As
manually I can save or copy the file to sharepoint, I just can't understand
why it is difficult to do it programmically.

"Barb Reinhardt" wrote in message
...
I've mapped sharepoint drives that I access frequently to an available
drive
letter.. I've found that I need to make sure that the WebClient service
is
running to be able to access it that way though.

HTH,
Barb Reinhardt

"Hii Sing Chung" wrote:

Dear Patrick,

I already assigned the variable strFileName to
""http://myweb:8585/sites/it_security/monitoring/Shared
Documents/Management
Reports/Daily Reports.xls". If I use "test" it will work. It failed
because
it is not a filesystem path, it is an http path, so my question is how to
tell Excel to use http as path or something like that. Alternatively, is
there a way to get around this limitation so that I can met my
requirement
of uploading file to a Sharepoint site automatically.

"Patrick Molloy" wrote in
message
...
try changing the file name. Your code uses this variable strFileName ,
which
is the file that you opened. try
ThisWorkbook.SaveCopyAs "Test"

and see where it gest saved to

"Hii Sing Chung" wrote:

I would like to have VBA to automatically/programmically upload an
Excel
file to a Sharepoint site. I tried the code below but got 'File not
Found'
error. I could manually save as the file to the same path, so the path
is
correct. Any suggestions?
Sub PostToSharepoint()
Dim wbBook As Workbook
Dim wsSheet As Worksheet
Dim strWorkSheet As String
Dim cell As Range
Dim strFileName
strWorkSheet = Format(Date - 1, "mmmmyy")
Set wbBook = ThisWorkbook
Set wsSheet = ThisWorkbook.Sheets(strWorkSheet)
wsSheet.Activate
strFileName =
"http://myweb:8585/sites/it_security/monitoring/Shared
Documents/Management Reports/Daily Reports.xls"
For Each cell In Range(Range("B4"), Range("B34"))
If cell.Value <= Now() - 1 And IsFormula(cell.Offset(0,
1)) =
True Then
cell.Range(cell.Offset(0, 1), cell.Offset(0, 4)).Copy
Range(cell.Offset(0, 1), cell.Offset(0,
4)).PasteSpecial
(xlPasteValues)
End If
Next cell
ThisWorkbook.SaveCopyAs Filename:=strFileName 'File not found
error
occurred'
End Sub
Function IsFormula(Check_Cell As Range)
IsFormula = Check_Cell.HasFormula
End Function



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
Upload an Excel file? Stan in South Africa Excel Discussion (Misc queries) 3 May 3rd 09 06:03 AM
Sharepoint: How do I upload Excel (2003) Reports to Sharepoint? [email protected] Excel Programming 0 January 29th 09 11:34 AM
Upload back changes made in downloaded Excel copy to SharePoint Li Amitabh Excel Discussion (Misc queries) 0 September 27th 07 08:02 AM
Upload to sharepoint Lp12 Excel Programming 1 March 17th 06 05:49 PM
Reading an Excel file after upload Quan[_2_] Excel Programming 0 November 6th 03 12:12 AM


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