Home

Macros and Programming

 

CardboxForumsMacros and Programming > "macro to save pictures to disk"

macro to save pictures to disk

Is it possible to save images (pictures) from my Cardbox records to harddisk?

Current user: [none]
Register / Log In · Help

Posted By Post

herman.cbx

17-Oct-2012 12:54

I want to make a macro to save pictures from my records to harddisk, but when you start recording a macro the image button is greyed out. How can I solve this problem?

bert

18-Oct-2012 08:11

Silence....!

A lot of functions you cannot record with the macro recorder.
It is very a pity: a batch-export function for images is a lack of Cardbox. This is really one of the big lacks in Cardbox.
However,with the help function, the macro recorder, and a lot of macro practice, you can program something...
To save your time I can offer you this below.
Copy and pate the macro to a macro and it will do what you want.
Any appreciation is welcome.

Regards
Bert

'--------------
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Select folder:", 16384, 16)
If objFolder Is Nothing Then Halt
fld = objFolder.self.path
If Right(fld,1) <> "\" Then fld = fld & "\"

for x = Recordposition to Records.Count
   Set rec = activerecord
   fi = "record_" & x
   for n = 1 to rec.Images.Count
      Set img=rec.Images.Item(n)
      img.WriteToFile fld & fi & "_" & n & ".jpg" , cbxImageNonBMP+cbxImageOverwriteFile
   next
   nextRecord
next
'--------------

herman.cbx

18-Oct-2012 09:37

Thank you very much Bert. It works!

But is it also possible to give a (unique) fieldname to the saved picture, not only a number?

Herman

bert

18-Oct-2012 12:02

Of course...
If you have in a field a unique name of the picture, than you can use that of course.
Remember in this case the file name convention in Windows! (so in that field cannot be not allowed Windows-filename-characters like / and \ b.e.

Replace
  fi = "record_" & x
for
  fi = "Fields("NAME_OF_YOUR_FIELD")

For the case you stored more than one image in a record, always a number is added to the content of the field.

If you have in your field not unique terms, there is a risk you overwrite just written images.

Regards
Bert

herman.cbx

18-Oct-2012 12:16

Thank you Bert,

it works, great!

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home