Copy File from Website (Sharepoint)

J

J Streger

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
 
J

Joel

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

J Streger

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
 
J

Joel

It doesn't error because you have "On Error Resume Next". Comment out this
line and see if you get an error.
 
J

J Streger

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
 
C

CathyZ

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top