Solved

VB code error

Posted on 2014-01-30
4
413 Views
Last Modified: 2014-02-10
We have this piece of code that is not working as expected. The file is supposed to be copied automatically to Sharepoint using the script but it doesn't. I'm not an expert here so wanted to see if someone can help with figuring this out. Thanks.

'Copy Image file to Sharepoint
'On Error GoTo ErrorFileCopyMLKSummary
'fso.CopyFile strLocLan & "MLK_Summary.jpg", strLocSP & "MLK Summary\MLK_Summary.jpg", True
On Error GoTo ErrorHandler

Set fso = Nothing
CreateDQIMTotals = True
Exit Function
ErrorHandler: MsgBox "CreateMLKTotals: " & Err.Description: Set fso = Nothing: CreateMLKTotals = False: Exit Function
ErrorFileCopyMLKSummary: If fso.FileExists(strLocSP & "MLK Summary\MLK_Summary.jpg") Then fso.DeleteFile strLocSP & "MLK Summary\MLK_Summary.jpg", True: fso.CopyFile strLocLan & "MLK_Summary.jpg", strLocSP & "MLK Summary\MLK_Summary.jpg": Resume Next
End Function

Open in new window

0
Comment
Question by:kris24
4 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 39823091
Well the 2nd and 3rd lines have been commented out so that could be your problem, remove the apostrophe at the start of line 2 and 3 shown above.
0
 
LVL 54

Expert Comment

by:Bill Prew
ID: 39823130
That code isn't enough to see what's going on.  I see an exit function and there isn't even a function defined.

It also currently looks like the only way you get to a copy file statement is on an error, which doesn't really make sense.

What changes were made to the code recently?

What other changes might have caused it to stop working?

~bp
0
 
LVL 81

Expert Comment

by:byundt
ID: 39824043
Do variables strLocLan and strLocSP end with the requisite path separator characters? If not, you may be inadvertently referring to paths that don't exist.
0
 
LVL 2

Accepted Solution

by:
MarkRR earned 500 total points
ID: 39824304
The desination parameter should be a folder location it does not need the filename "MLK_Summary.jpg"

'fso.CopyFile strLocLan & "MLK_Summary.jpg", strLocSP & "MLK Summary\", True
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question