PC Review


Reply
Thread Tools Rate Thread

Copy File from Website (Sharepoint)

 
 
J Streger
Guest
Posts: n/a
 
      13th Feb 2008
I have a tools suite that I have linked to an .xla in order to allow it to be
utilized at all times. I have everyone install an xla that just opens the
tools xla. this way I can update my tools xla and the updates are invisible
to the end user. Well now we have a sharepoint that stores the files, and I
can open them from Excel, but trying to use FileCopy on the website file just
fails. My code looks like:

Sub InstallAddin()

'********************************************************************
'* *
'* This will install the Useful Tools Addin onto the user's copy *
'* of Excel. *
'* *
'********************************************************************

'VAR

Dim sCurLoc As String
Dim sAddinLibLoc As String
Dim sFileName As String
Dim iVerify As Integer
Dim fso As Object

'BEGIN
'Confirm installation. Allow for modifications
iVerify = MsgBox("Are you sure you wish to install " & vbCrLf & _
"Useful tools as an add-in?", vbYesNo)
If iVerify = vbYes Then
'set file name
sFileName = glUSETOOLS & ".xla"
On Error Resume Next

'get current location of addin and location of library path
sCurLoc = ThisWorkbook.Path & "/" & sFileName
'set location for addin. each person needs a local addin
sAddinLibLoc = Application.LibraryPath & "\" & sFileName
'If destination already has file, delete
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.fileexists(sAddinLibLoc) Then Kill sAddinLibLoc

'Close the xla if open to allow for reinstall
Workbooks(sFileName).Close False
'Copy addin in the Excel Library
'MY PROBLEM IS HERE
FileCopy sCurLoc, sAddinLibLoc

'Install Addin in Excel
With AddIns.Add(Filename:=sAddinLibLoc)
.Installed = True
End With
'Close Installer
ThisWorkbook.Close False
On Error GoTo 0
End If

End Sub 'InstallAddin

I verified all the paths to ensure they are pointing to the correct places.
the user opens an .xls file that runs the code, and installs the .xla that is
located in the same path, copying the xla to their addin library.

So is there another way to copy the file from a website to a harddrive than
FileCopy?

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003

 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      13th Feb 2008
Filecopy should work. Check the file name again.

Either
\\microsoft.com\abc\cde.xls
or
h:\abc\cde.xls

A web URL should not require the http:
A Path drive should have the first back-slash

"J Streger" wrote:

> I have a tools suite that I have linked to an .xla in order to allow it to be
> utilized at all times. I have everyone install an xla that just opens the
> tools xla. this way I can update my tools xla and the updates are invisible
> to the end user. Well now we have a sharepoint that stores the files, and I
> can open them from Excel, but trying to use FileCopy on the website file just
> fails. My code looks like:
>
> Sub InstallAddin()
>
> '********************************************************************
> '* *
> '* This will install the Useful Tools Addin onto the user's copy *
> '* of Excel. *
> '* *
> '********************************************************************
>
> 'VAR
>
> Dim sCurLoc As String
> Dim sAddinLibLoc As String
> Dim sFileName As String
> Dim iVerify As Integer
> Dim fso As Object
>
> 'BEGIN
> 'Confirm installation. Allow for modifications
> iVerify = MsgBox("Are you sure you wish to install " & vbCrLf & _
> "Useful tools as an add-in?", vbYesNo)
> If iVerify = vbYes Then
> 'set file name
> sFileName = glUSETOOLS & ".xla"
> On Error Resume Next
>
> 'get current location of addin and location of library path
> sCurLoc = ThisWorkbook.Path & "/" & sFileName
> 'set location for addin. each person needs a local addin
> sAddinLibLoc = Application.LibraryPath & "\" & sFileName
> 'If destination already has file, delete
> Set fso = CreateObject("Scripting.FileSystemObject")
> If fso.fileexists(sAddinLibLoc) Then Kill sAddinLibLoc
>
> 'Close the xla if open to allow for reinstall
> Workbooks(sFileName).Close False
> 'Copy addin in the Excel Library
> 'MY PROBLEM IS HERE
> FileCopy sCurLoc, sAddinLibLoc
>
> 'Install Addin in Excel
> With AddIns.Add(Filename:=sAddinLibLoc)
> .Installed = True
> End With
> 'Close Installer
> ThisWorkbook.Close False
> On Error GoTo 0
> End If
>
> End Sub 'InstallAddin
>
> I verified all the paths to ensure they are pointing to the correct places.
> the user opens an .xls file that runs the code, and installs the .xla that is
> located in the same path, copying the xla to their addin library.
>
> So is there another way to copy the file from a website to a harddrive than
> FileCopy?
>
> --
> *********************
> J Streger
> MS Office Master 2000 ed.
> MS Project White Belt 2003
>
> User of MS Office 2003
>

 
Reply With Quote
 
J Streger
Guest
Posts: n/a
 
      13th Feb 2008
I verified all paths as I stepped through the code. The FileCopy fucntion
doesn't error out, just doesn't copy the file. I took the strings I was
passing into the FileCopy method and used those same stings in a
Workbooks.open method and the workbook opened, so I know the path is correct.

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003



"Joel" wrote:

> Filecopy should work. Check the file name again.
>
> Either
> \\microsoft.com\abc\cde.xls
> or
> h:\abc\cde.xls
>
> A web URL should not require the http:
> A Path drive should have the first back-slash
>
> "J Streger" wrote:
>
> > I have a tools suite that I have linked to an .xla in order to allow it to be
> > utilized at all times. I have everyone install an xla that just opens the
> > tools xla. this way I can update my tools xla and the updates are invisible
> > to the end user. Well now we have a sharepoint that stores the files, and I
> > can open them from Excel, but trying to use FileCopy on the website file just
> > fails. My code looks like:
> >
> > Sub InstallAddin()
> >
> > '********************************************************************
> > '* *
> > '* This will install the Useful Tools Addin onto the user's copy *
> > '* of Excel. *
> > '* *
> > '********************************************************************
> >
> > 'VAR
> >
> > Dim sCurLoc As String
> > Dim sAddinLibLoc As String
> > Dim sFileName As String
> > Dim iVerify As Integer
> > Dim fso As Object
> >
> > 'BEGIN
> > 'Confirm installation. Allow for modifications
> > iVerify = MsgBox("Are you sure you wish to install " & vbCrLf & _
> > "Useful tools as an add-in?", vbYesNo)
> > If iVerify = vbYes Then
> > 'set file name
> > sFileName = glUSETOOLS & ".xla"
> > On Error Resume Next
> >
> > 'get current location of addin and location of library path
> > sCurLoc = ThisWorkbook.Path & "/" & sFileName
> > 'set location for addin. each person needs a local addin
> > sAddinLibLoc = Application.LibraryPath & "\" & sFileName
> > 'If destination already has file, delete
> > Set fso = CreateObject("Scripting.FileSystemObject")
> > If fso.fileexists(sAddinLibLoc) Then Kill sAddinLibLoc
> >
> > 'Close the xla if open to allow for reinstall
> > Workbooks(sFileName).Close False
> > 'Copy addin in the Excel Library
> > 'MY PROBLEM IS HERE
> > FileCopy sCurLoc, sAddinLibLoc
> >
> > 'Install Addin in Excel
> > With AddIns.Add(Filename:=sAddinLibLoc)
> > .Installed = True
> > End With
> > 'Close Installer
> > ThisWorkbook.Close False
> > On Error GoTo 0
> > End If
> >
> > End Sub 'InstallAddin
> >
> > I verified all the paths to ensure they are pointing to the correct places.
> > the user opens an .xls file that runs the code, and installs the .xla that is
> > located in the same path, copying the xla to their addin library.
> >
> > So is there another way to copy the file from a website to a harddrive than
> > FileCopy?
> >
> > --
> > *********************
> > J Streger
> > MS Office Master 2000 ed.
> > MS Project White Belt 2003
> >
> > User of MS Office 2003
> >

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      13th Feb 2008
It doesn't error because you have "On Error Resume Next". Comment out this
line and see if you get an error.


"J Streger" wrote:

> I verified all paths as I stepped through the code. The FileCopy fucntion
> doesn't error out, just doesn't copy the file. I took the strings I was
> passing into the FileCopy method and used those same stings in a
> Workbooks.open method and the workbook opened, so I know the path is correct.
>
> --
> *********************
> J Streger
> MS Office Master 2000 ed.
> MS Project White Belt 2003
>
> User of MS Office 2003
>
>
>
> "Joel" wrote:
>
> > Filecopy should work. Check the file name again.
> >
> > Either
> > \\microsoft.com\abc\cde.xls
> > or
> > h:\abc\cde.xls
> >
> > A web URL should not require the http:
> > A Path drive should have the first back-slash
> >
> > "J Streger" wrote:
> >
> > > I have a tools suite that I have linked to an .xla in order to allow it to be
> > > utilized at all times. I have everyone install an xla that just opens the
> > > tools xla. this way I can update my tools xla and the updates are invisible
> > > to the end user. Well now we have a sharepoint that stores the files, and I
> > > can open them from Excel, but trying to use FileCopy on the website file just
> > > fails. My code looks like:
> > >
> > > Sub InstallAddin()
> > >
> > > '********************************************************************
> > > '* *
> > > '* This will install the Useful Tools Addin onto the user's copy *
> > > '* of Excel. *
> > > '* *
> > > '********************************************************************
> > >
> > > 'VAR
> > >
> > > Dim sCurLoc As String
> > > Dim sAddinLibLoc As String
> > > Dim sFileName As String
> > > Dim iVerify As Integer
> > > Dim fso As Object
> > >
> > > 'BEGIN
> > > 'Confirm installation. Allow for modifications
> > > iVerify = MsgBox("Are you sure you wish to install " & vbCrLf & _
> > > "Useful tools as an add-in?", vbYesNo)
> > > If iVerify = vbYes Then
> > > 'set file name
> > > sFileName = glUSETOOLS & ".xla"
> > > On Error Resume Next
> > >
> > > 'get current location of addin and location of library path
> > > sCurLoc = ThisWorkbook.Path & "/" & sFileName
> > > 'set location for addin. each person needs a local addin
> > > sAddinLibLoc = Application.LibraryPath & "\" & sFileName
> > > 'If destination already has file, delete
> > > Set fso = CreateObject("Scripting.FileSystemObject")
> > > If fso.fileexists(sAddinLibLoc) Then Kill sAddinLibLoc
> > >
> > > 'Close the xla if open to allow for reinstall
> > > Workbooks(sFileName).Close False
> > > 'Copy addin in the Excel Library
> > > 'MY PROBLEM IS HERE
> > > FileCopy sCurLoc, sAddinLibLoc
> > >
> > > 'Install Addin in Excel
> > > With AddIns.Add(Filename:=sAddinLibLoc)
> > > .Installed = True
> > > End With
> > > 'Close Installer
> > > ThisWorkbook.Close False
> > > On Error GoTo 0
> > > End If
> > >
> > > End Sub 'InstallAddin
> > >
> > > I verified all the paths to ensure they are pointing to the correct places.
> > > the user opens an .xls file that runs the code, and installs the .xla that is
> > > located in the same path, copying the xla to their addin library.
> > >
> > > So is there another way to copy the file from a website to a harddrive than
> > > FileCopy?
> > >
> > > --
> > > *********************
> > > J Streger
> > > MS Office Master 2000 ed.
> > > MS Project White Belt 2003
> > >
> > > User of MS Office 2003
> > >

 
Reply With Quote
 
J Streger
Guest
Posts: n/a
 
      13th Feb 2008
Thanks for that. Was wondering why it wasn't erroring out on me.

And I misunderstood your post to mean you don't need the Http:, not the fact
that you can't have the Http: preceding the file name. Regardless, thanks for
helping me!

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003



"Joel" wrote:

> It doesn't error because you have "On Error Resume Next". Comment out this
> line and see if you get an error.
>
>
> "J Streger" wrote:
>
> > I verified all paths as I stepped through the code. The FileCopy fucntion
> > doesn't error out, just doesn't copy the file. I took the strings I was
> > passing into the FileCopy method and used those same stings in a
> > Workbooks.open method and the workbook opened, so I know the path is correct.
> >
> > --
> > *********************
> > J Streger
> > MS Office Master 2000 ed.
> > MS Project White Belt 2003
> >
> > User of MS Office 2003
> >
> >
> >
> > "Joel" wrote:
> >
> > > Filecopy should work. Check the file name again.
> > >
> > > Either
> > > \\microsoft.com\abc\cde.xls
> > > or
> > > h:\abc\cde.xls
> > >
> > > A web URL should not require the http:
> > > A Path drive should have the first back-slash
> > >
> > > "J Streger" wrote:
> > >
> > > > I have a tools suite that I have linked to an .xla in order to allow it to be
> > > > utilized at all times. I have everyone install an xla that just opens the
> > > > tools xla. this way I can update my tools xla and the updates are invisible
> > > > to the end user. Well now we have a sharepoint that stores the files, and I
> > > > can open them from Excel, but trying to use FileCopy on the website file just
> > > > fails. My code looks like:
> > > >
> > > > Sub InstallAddin()
> > > >
> > > > '********************************************************************
> > > > '* *
> > > > '* This will install the Useful Tools Addin onto the user's copy *
> > > > '* of Excel. *
> > > > '* *
> > > > '********************************************************************
> > > >
> > > > 'VAR
> > > >
> > > > Dim sCurLoc As String
> > > > Dim sAddinLibLoc As String
> > > > Dim sFileName As String
> > > > Dim iVerify As Integer
> > > > Dim fso As Object
> > > >
> > > > 'BEGIN
> > > > 'Confirm installation. Allow for modifications
> > > > iVerify = MsgBox("Are you sure you wish to install " & vbCrLf & _
> > > > "Useful tools as an add-in?", vbYesNo)
> > > > If iVerify = vbYes Then
> > > > 'set file name
> > > > sFileName = glUSETOOLS & ".xla"
> > > > On Error Resume Next
> > > >
> > > > 'get current location of addin and location of library path
> > > > sCurLoc = ThisWorkbook.Path & "/" & sFileName
> > > > 'set location for addin. each person needs a local addin
> > > > sAddinLibLoc = Application.LibraryPath & "\" & sFileName
> > > > 'If destination already has file, delete
> > > > Set fso = CreateObject("Scripting.FileSystemObject")
> > > > If fso.fileexists(sAddinLibLoc) Then Kill sAddinLibLoc
> > > >
> > > > 'Close the xla if open to allow for reinstall
> > > > Workbooks(sFileName).Close False
> > > > 'Copy addin in the Excel Library
> > > > 'MY PROBLEM IS HERE
> > > > FileCopy sCurLoc, sAddinLibLoc
> > > >
> > > > 'Install Addin in Excel
> > > > With AddIns.Add(Filename:=sAddinLibLoc)
> > > > .Installed = True
> > > > End With
> > > > 'Close Installer
> > > > ThisWorkbook.Close False
> > > > On Error GoTo 0
> > > > End If
> > > >
> > > > End Sub 'InstallAddin
> > > >
> > > > I verified all the paths to ensure they are pointing to the correct places.
> > > > the user opens an .xls file that runs the code, and installs the .xla that is
> > > > located in the same path, copying the xla to their addin library.
> > > >
> > > > So is there another way to copy the file from a website to a harddrive than
> > > > FileCopy?
> > > >
> > > > --
> > > > *********************
> > > > J Streger
> > > > MS Office Master 2000 ed.
> > > > MS Project White Belt 2003
> > > >
> > > > User of MS Office 2003
> > > >

 
Reply With Quote
 
CathyZ
Guest
Posts: n/a
 
      19th Jun 2008
Can you tell me why when I use FileCopy(srcFile, DestFile)
and my srcFile = "\\inettest.state.me.us\macwis\macprog.txt" (srcFile was
declared as String)
that I get an error saying URI format cannot be used?

Thanks,
Cathy Z

"Joel" wrote:

> Filecopy should work. Check the file name again.
>
> Either
> \\microsoft.com\abc\cde.xls
> or
> h:\abc\cde.xls
>
> A web URL should not require the http:
> A Path drive should have the first back-slash
>
> "J Streger" wrote:
>
> > I have a tools suite that I have linked to an .xla in order to allow it to be
> > utilized at all times. I have everyone install an xla that just opens the
> > tools xla. this way I can update my tools xla and the updates are invisible
> > to the end user. Well now we have a sharepoint that stores the files, and I
> > can open them from Excel, but trying to use FileCopy on the website file just
> > fails. My code looks like:
> >
> > Sub InstallAddin()
> >
> > '********************************************************************
> > '* *
> > '* This will install the Useful Tools Addin onto the user's copy *
> > '* of Excel. *
> > '* *
> > '********************************************************************
> >
> > 'VAR
> >
> > Dim sCurLoc As String
> > Dim sAddinLibLoc As String
> > Dim sFileName As String
> > Dim iVerify As Integer
> > Dim fso As Object
> >
> > 'BEGIN
> > 'Confirm installation. Allow for modifications
> > iVerify = MsgBox("Are you sure you wish to install " & vbCrLf & _
> > "Useful tools as an add-in?", vbYesNo)
> > If iVerify = vbYes Then
> > 'set file name
> > sFileName = glUSETOOLS & ".xla"
> > On Error Resume Next
> >
> > 'get current location of addin and location of library path
> > sCurLoc = ThisWorkbook.Path & "/" & sFileName
> > 'set location for addin. each person needs a local addin
> > sAddinLibLoc = Application.LibraryPath & "\" & sFileName
> > 'If destination already has file, delete
> > Set fso = CreateObject("Scripting.FileSystemObject")
> > If fso.fileexists(sAddinLibLoc) Then Kill sAddinLibLoc
> >
> > 'Close the xla if open to allow for reinstall
> > Workbooks(sFileName).Close False
> > 'Copy addin in the Excel Library
> > 'MY PROBLEM IS HERE
> > FileCopy sCurLoc, sAddinLibLoc
> >
> > 'Install Addin in Excel
> > With AddIns.Add(Filename:=sAddinLibLoc)
> > .Installed = True
> > End With
> > 'Close Installer
> > ThisWorkbook.Close False
> > On Error GoTo 0
> > End If
> >
> > End Sub 'InstallAddin
> >
> > I verified all the paths to ensure they are pointing to the correct places.
> > the user opens an .xls file that runs the code, and installs the .xla that is
> > located in the same path, copying the xla to their addin library.
> >
> > So is there another way to copy the file from a website to a harddrive than
> > FileCopy?
> >
> > --
> > *********************
> > J Streger
> > MS Office Master 2000 ed.
> > MS Project White Belt 2003
> >
> > User of MS Office 2003
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using VB code to copy file to Sharepoint document Library Dj Microsoft Access Getting Started 0 12th May 2008 09:45 PM
Copy a file from website Bonnie Microsoft Frontpage 2 3rd Feb 2008 08:20 PM
Faster and more efficient ways to copy website content from VS.NET interface (besides the "Copy Website" tool?) Microsoft ASP .NET 4 27th Aug 2007 10:52 AM
File copy to sharepoint using MS Access =?Utf-8?B?SmFtZXM=?= Microsoft Access VBA Modules 1 1st Sep 2005 01:21 PM
How to link table to excel file on windows sharepoint website? =?Utf-8?B?bmVlbG5w?= Microsoft Access External Data 0 27th Jul 2005 07:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:25 AM.