Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I'm trying copy & paste the images from location to another location. While pasting image, the image name should change in suffix should have with another field name.
i.e; LotNo-ImageName
Below is the my macro code, how can i add suffixname when pasting image to destination folder
Here
vImagesLocation = C:\ImageSource\
vImagesDestination = D:\ImageDestination\
vLensInspectionImageNames = GetFieldSelections(ImageName,',','*') Ex : 2012_1030_153442_664.bmp (In vImageLocation images having this kind of names)
Now when saving in vImagesDestination it should save as 100123-2012_1030_153442_664.bmp (Consider here the LotNo for this file is 100123).
Please let me know what i needs to add in code to get exact output what i expected.
Sub CopyPasteImages
Dim sOriginFolder, sDestinationFolder, sFile, oFSO,
Dim iCount
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set vLensInspectionImageNames=ActiveDocument.Variables("vLensInspectionImageNames")
Set vImageSourcePath=ActiveDocument.Variables("vImagesLocation")
Set vImageDestinationPath=ActiveDocument.Variables("vImagesDestination")
ArrFields = split(vLensInspectionImageNames.GetContent.String, ",")
iCount = 0
For Each fIndex in ArrFields
sOriginFolder = vImageSourcePath.GetContent.string&fIndex
sDestinationFolder = vImageDestinationPath.GetContent.string&fIndex
sFileNameExtension = vImageNameExtension.GetContent.string
if oFSO.fileExists(sOriginFolder) then
iCount = iCount + 1
oFSO.CopyFile sOriginFolder, sDestinationFolder
end if
If iCount >=1000 then Exit Sub
Next
End Sub
Thanks in advance
Maybe like this (untested):
For Each fIndex in ArrFields
sOriginFolder = vImageSourcePath.GetContent.string&fIndex
ActiveDocument.Fields("ImageName").Select fIndex
vPV = ActiveDocument.Fields("LotNo").GetPossibleValues
LotNo = vPV.Item(0).Text
sDestinationFolder = vImageDestinationPath.GetContent.string&LotNo&'-'&fIndex
sFileNameExtension = vImageNameExtension.GetContent.string
if oFSO.fileExists(sOriginFolder) then
iCount = iCount + 1
oFSO.CopyFile sOriginFolder, sDestinationFolder
end if
If iCount >=1000 then Exit Sub
Next
Hi Gysbert,
Yes it is getting LotNo name suffix to imagename, but currently for every image the lotno is getting same
Actually imagenames having different lotno's.
What i needs to change in your code to get the same LotNo for that particular ImageName ?
Thanks in advance.
Hi can anyone help on this. It is urgent !!!
Thanks in advance