Solved

VB code error

Posted on 2014-01-30
4
409 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 52

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now