Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automated image import in Access

Status
Not open for further replies.

gasca

Programmer
Apr 2, 2003
22
ES
Hi,

Anyone's got any clue on how to import automatically some jpg pictures into an OLE Object data field using some VBA code in Access? Let's say I have every picture named in a uniform way (identifier of register,...)

Thanks.
 
There is probably a much better way but this worked with a number of bmp files using PaintShop Pro and AppActivate to switch between the programs. It was some time ago with OFFICE 97 but AppActivate is still in 2000

Function Getpics()
'pictures are named 0438.bmp to 0740.bmp

For a = 438 To 740

fno = Str(a)
fno = Right(fno, Len(fno) - 1) 'remove the sign from the number
While Len(fno) < 4
fno = &quot;0&quot; + fno ' add leading zeros
Wend

fname = &quot;n:\ew\98pics\march\&quot; + fno + &quot;.bmp&quot;
AppActivate &quot;Paint Shop Pro&quot;
SendKeys &quot;%Fc%Fo&quot; + fname + &quot;{enter}&quot;, True 'open file
SendKeys &quot;%EC&quot;, True 'copy it
AppActivate &quot;Microsoft Access&quot;
SendKeys &quot;%W4&quot; + fname + &quot;{RIGHT}%EP{RIGHT}&quot;, True ' paste it in second column

Next
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top