Consulting

Results 1 to 14 of 14

Thread: Solved: Capture picture, save to folder and create hyperlink in cell?

  1. #1
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location

    Solved: Capture picture, save to folder and create hyperlink in cell?

    Hi all, is it possible to, on the click of a command button take a picture using a webcam (or other such device) name it, save it to a folder and create a hyperlink to it in a cell?

    My intention is that when a new employee is recruited and a userform is filled in (already created that) when the command button to commit the data is clicked i would like to be able to automatically take a picture of the employee save the picture as lets say TextBox1.Value store it in a folder called "Employee ID" (if it's not present create it) and then create a hyperlink to it in Sheets("Staff Details").Range("A1") (ficticious location as the location will be determined by the userform finding last entry and and using Rng.Offset to place the hyperlink in the cell).

    This way ID badges can be made easily plus when employee records are called up a face will be put to the name (not only important for payment to the employee as they will mostly be agency workers but for security and legal reasons).

    Any thoughts and ideas on how to accomplish this?

    Regards,
    Simon
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  2. #2
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    I am 100% sure that this is possible, but I'm also 100% sure that I can't tell you how. LOL! Does that help?

    Reason I say it's possible is that there are many applications I've seen in the wild that will snap a pic and return it to a userform. The questions, though, comes down to:
    -Does the camera expose its object model to code?
    -Is there an API that you can use to trigger it?
    -What format is the default output?

    Once you've got all that, then things might be easy. Copying/renaming/deleting files is really easy in VB(A), so you'd just need to find the most recent picture and move/rename it to what you want. I'm sure that you'd be able to come across code on the internet to convert and scale your picture from one format to another. And from there it's importing it into your userform which again should be do-able.

    The part that gives me most cause for concern is sending commands to your camera. Now... if you had a camera that always snapped a pic and dumped it immediately into a directory... Then you could just manually tigger your macro after you'd taken the picture. Copy it to a new folder, rename it, delete the original, and you're always clean for next time. Then it's the image conversion etc...

    Hopefully some of this helps a bit conceptually, if nothing else.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  3. #3
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Ken thanks for the analysis, you can see what i'm getting at though, it doesn't need to be available to the userform, its just if she fills in the userform that records an employees details i wanted on close to be able to snap the employee, save it as employee name perhaps in a designated folder and then deposit a hyperlink for it at the end of the employee record.

    Not being very experienced in VBA i wouldnt have the foggiest idea on manipulating applications outside of Excel, the hyperlink i could probably work out (but on second thoughts i only want the hyperlink to call the picture in to excel temporary for printing or inclusion in a report). I have no idea what API is or means at a guess Advanced Program Interface, but that still doesnt tell me anything.

    I will trawl the internet for any other solutions.....i asked the question here first because this is where the experts hang out! LOL i don't class myself in that category but you never know rubbing shoulders and some may rub off!

    Regards,
    Simon
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I would have thought it simplest just to buy a product that does all of that. Sometimes it is not worth re-inventing the wheel.

  5. #5
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Bob, i agree but unless it's really cheap funds will not allow,Susan gave up her full time job to allow me to take on a different position at work, so running her own business seems to be the only option to give us a little financial freedom!, i have been trawling the net for such software but haven't come across any as yet.

    Regards,
    Simon
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  6. #6
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Simon
    I put together a utility here for handling photos in Excel. There might be some bits of it you can use.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Malcom, it's greatly appreciated, as i agreed with Bob, i believe the relevant software should be purchased, in fact i believe everyone should be paid for their efforts as it's nice to be appreciated but appreciation doesn't feed you!.....that aside if we could afford it it would save me all the trouble of putting together a package she can use now and in the future.....although it won't have the standards of folk on here i will post the final version for all to see and use if they wish!

    Regards,
    Simon
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  8. #8
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    If you have a dedicated ID camera that is always connected to the same computor port, its' internal folder should be available to VBA as its' location and name won't change..

    Most cameras save in JPEG format and there is a JPEG filter for Excel.

    You would have to take the picture before triggering the Insert method.
    [VBA]ActiveSheet.Pictures.Insert("D:\Desktop\167335230.jpg").Select[/VBA]
    Is the macro I just recorded.

    You would have to set a Var to the path and find the picture name somehow.

  9. #9
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Quote Originally Posted by SamT
    You would have to set a Var to the path and find the picture name somehow.
    You could use DateCreated to determine the newest file in the folder.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  10. #10
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Linked to http://vbaexpress.com/forum/showthread.php?t=12567 in a way

    Regards,
    Simon
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  11. #11
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Quote Originally Posted by xld
    I would have thought it simplest just to buy a product that does all of that. Sometimes it is not worth re-inventing the wheel.
    True enough, but this does seem pretty interesting.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  12. #12
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Ken Puls
    True enough, but this does seem pretty interesting.
    Maybe for a sad old git like you , but I have too many other things to do rather than to spend time on something that someone else can invariably do better with appropriate tools.

    Fancy having a crack at an Excel/VBA file compressor/de-compressor?

  13. #13
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Old? Ouch! LOL!

    I'll ping you offline about the other.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  14. #14
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Marking this thread solved as i am following an alternative route here http://vbaexpress.com/forum/showthread.php?t=12567

    Thanks to all those that replied!

    Regards,
    Simon
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •