Solved

VB code error

Posted on 2014-01-30
4
412 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 53

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 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…

860 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