Solved

VB code error

Posted on 2014-01-30
4
407 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 51

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 80

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

707 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

12 Experts available now in Live!

Get 1:1 Help Now