Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-01-2015, 08:43 AM
saurabhlotankar saurabhlotankar is offline Copy images from one folder to another Windows XP Copy images from one folder to another Office 2010 32bit
Novice
Copy images from one folder to another
 
Join Date: May 2015
Posts: 29
saurabhlotankar is on a distinguished road
Default Copy images from one folder to another

Hi Guys,



I have one excel sheet in which i have names of images saved on my local drive.
I want to copy and paste images mentioned in column B from one folder to another folder.
Just for example i have give source and destination folder names (Path) also in attached excel sheet.

I want to know is it possible through VBA macro.

Thanks,
Saurabh
Reply With Quote
  #2  
Old 07-01-2015, 08:46 AM
saurabhlotankar saurabhlotankar is offline Copy images from one folder to another Windows XP Copy images from one folder to another Office 2010 32bit
Novice
Copy images from one folder to another
 
Join Date: May 2015
Posts: 29
saurabhlotankar is on a distinguished road
Default

Sorry guys..Here is the excel file.

Numbers mentioned in column B are image file names. .png or .jpeg format
Attached Files
File Type: xlsx Images.xlsx (9.5 KB, 10 views)
Reply With Quote
  #3  
Old 07-01-2015, 09:37 AM
NoSparks NoSparks is offline Copy images from one folder to another Windows 7 64bit Copy images from one folder to another Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

Have a look at the VBA section on this page and post back with the macro you are working with.
Reply With Quote
  #4  
Old 07-01-2015, 11:59 PM
saurabhlotankar saurabhlotankar is offline Copy images from one folder to another Windows XP Copy images from one folder to another Office 2010 32bit
Novice
Copy images from one folder to another
 
Join Date: May 2015
Posts: 29
saurabhlotankar is on a distinguished road
Default

Hi,

I have tried writing this code with the help of my friend.

Sub copyPNGfiles()

Dim fso As Scripting.FileSystemObject
Dim fldFrom As Scripting.Folder, fldTo As Scripting.Folder
Dim file As Scripting.file
Set fso = New FileSystemObject
Set fldFrom = fso.GetFolder("P:\Report\ABCD_1")
Set fldTo = fso.GetFolder("P:\Report\ABCD_2")
For Each file In fldFrom.Files
If Right(file.Name, 4) = ".png" Then
file.Copy fldTo.Path & "\" & file.Name, True
End If
Next file

End Sub



But problem with this code is it copies all images from source folder to the destination folder. What we need is, we want to copy only those images which are mentioned in column B.

we are not able to link the code with that excel file.

Any help would be highly appreciated.

Thanks
Reply With Quote
  #5  
Old 07-02-2015, 07:37 AM
NoSparks NoSparks is offline Copy images from one folder to another Windows 7 64bit Copy images from one folder to another Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

It's simpler than that, this was the part of the linked to page meant for you to see
Code:
Dim SourceFile, DestinationFile As String
SourceFile = "SRCFILE"   ' Define source file name.
DestinationFile = "DESTFILE"   ' Define target file name.
FileCopy(SourceFile, DestinationFile)   ' Copy source to target.
your SourceFile would be your A cell & "\" & your B cell
your DestinationFile would be your C cell & "\" & your B cell

you need the above inside a For-Each-Next loop of the data rows of your sheet.
Reply With Quote
  #6  
Old 07-03-2015, 03:14 AM
saurabhlotankar saurabhlotankar is offline Copy images from one folder to another Windows XP Copy images from one folder to another Office 2010 32bit
Novice
Copy images from one folder to another
 
Join Date: May 2015
Posts: 29
saurabhlotankar is on a distinguished road
Default

Not able to do it.
Reply With Quote
  #7  
Old 07-03-2015, 05:34 AM
NoSparks NoSparks is offline Copy images from one folder to another Windows 7 64bit Copy images from one folder to another Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

Show us what you tried.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
copy from web and paste in a word document : no images are shown Ron Wolpa Word 5 09-11-2013 02:16 AM
Copy formatting setting between images on the slide pogonoforysci1 PowerPoint 11 08-10-2012 03:54 AM
Loop through folder of workbooks and copy range to other workbook Snvlsfoal Excel Programming 3 07-29-2011 05:55 AM
copy-pasting hyperlinked images: work only at the edges Xuanzang PowerPoint 0 12-07-2010 02:35 AM
Copy email to another folder loc Outlook 0 12-26-2006 07:39 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft