VBA

Moderators: PavlinII
Number of threads: 1673
Number of posts: 3078

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Image control in Excel, updating through code Posted by cjd on 1 Oct 2004 at 11:34 AM
I am creating a program in excel. The user needs to pick a picture from a normal combo-box which will then appear as an image on the worksheet.

the code I use for the macro is:

Sub update_data()
Sheet1.Cells(2, 2) = Sheet1.ComboBox1.Value
Sheet1.Image1.Picture = VBAProject.ThisWorkbook.Path + "\pics\"+ Sheet1.Cells(2, 2) + ".jpg"
End Sub
Report
Re: Image control in Excel, updating through code Posted by PavlinII on 3 Oct 2004 at 12:22 PM
: I am creating a program in excel. The user needs to pick a picture from a normal combo-box which will then appear as an image on the worksheet.
:
: the code I use for the macro is:
:
 Sub update_data()
    Sheet1.Cells(2, 2) = Sheet1.ComboBox1.Value
    Sheet1.Image1.Picture = LoadPicture(VBAProject.ThisWorkbook.Path & "\pics\" & Sheet1.ComboBox1.Value & ".jpg")
 End Sub
This should be enough..

(note: Do not use + for concating strings... it may cause unexpected things when u use magic data type conversions.. (all classic vb converstions))



Pavlin II[/size]

Don't take life too seriously anyway you won't escape alive from it!


Report
Re: Image control in Excel, updating through code Posted by cjd on 5 Oct 2004 at 7:49 AM
This message was edited by cjd at 2004-10-5 7:49:38

Thanx,
That worked





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.