Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB code error

Posted on 2014-01-30
4
Medium Priority
?
417 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 57

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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

670 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