+ Reply to Thread
Results 1 to 14 of 14

Form Load Picture form variable

  1. #1
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Form Load Picture form variable

    Im trying to loasd a pic of a userform using cell A1 as the referance for the file though i am going wrong somewhere.
    Ant idears
    Please Login or Register  to view this content.
    Thanks
    I though ild post a new topic since its a diffrent problem
    Last edited by D_Rennie; 06-21-2009 at 08:54 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Form Load Picture form variable

    Hello D_Rennie,

    Use the LoadPicture method to copy the picture from a file into a control.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Form Load Picture form variable

    Thanks Leith Ross.

    another questions though, After the sub has run the image will only appar if i go away from the form and then return (so after the sub i have to go to firefox then back to excel for the image to display). Does the form need to be refreshedd somehow.

    Thankyou

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Form Load Picture form variable

    Which version of Excel are you using?

    What's the reason for dong this?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Form Load Picture form variable

    2007 Without any service packs
    Reason, so i can store the path and file name in a cell and based on what a user enteres into combobox a picture related to that item can be displayed.
    Last edited by D_Rennie; 06-21-2009 at 08:17 AM.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Form Load Picture form variable

    Is the image control on a userform?

  7. #7
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Form Load Picture form variable

    what i done was,
    using the code that yu gave me to fill the combobox ive added a textbox and then when your code runs ive set the textbox value 2 to the right and used the textbox value for setting the Variant and it works like a charm

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Form Load Picture form variable

    I don't understand, why do yo need a textbox/ Are you loding an image to a userform?

  9. #9
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Form Load Picture form variable

    well i used the Application.GetOpenFilename with that i can store the file path and name into a cell.

    on another sub
    If i use the cell value to set the Variant for some reason the picture will only display like i said earler.

    Though if i change the textbox value to the cell vaule and then use the textbox value for setting the Variant it image loads straight away.
    .

    it all ties in with what you helped me with on the combobox.

    so a user sets the 1st combobox (Your code runs) and then 2nd combobox is selected then the textbox value is set. all in turn showing the picture for the selections.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Form Load Picture form variable

    You should declare a variable to hold the path, then set that variable with getopenfile.

    Have you looked at the DatabaseForm example which shows how to load images bsed on a Field in the dataset?

    http://www.excel-it.com/vba_examples.htm

  11. #11
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Form Load Picture form variable

    This is the workbook so far, Its kinda messy though.
    Attached Files Attached Files

  12. #12
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Form Load Picture form variable

    lol
    Thats pritty much what i was aming for,
    I was trying to make this like a database. Though though databases seamed like a scary thing. So instred i bug the hell out of all of you.
    I think some of my idears have been kinda sound.
    Cheers ill take a real close look.

  13. #13
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Form Load Picture form variable

    I like the way the row can be deleted and the thing with allowing admendments looks nice. the whole thing seams so simple when structured like that.

    there is a error when i click the goto last record or try and find a record. or all things it points to Me.Image1.Picture = LoadPicture(imgFolder & sFileName & ".jpg").
    Would the be a version thing.
    Should i get a copy of 2003 and use that.

  14. #14
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Form Load Picture form variable

    Quote Originally Posted by D_Rennie View Post
    I like the way the row can be deleted and the thing with allowing admendments looks nice. the whole thing seams so simple when structured like that.

    there is a error when i click the goto last record or try and find a record. or all things it points to Me.Image1.Picture = LoadPicture(imgFolder & sFileName & ".jpg").
    Would the be a version thing.
    Should i get a copy of 2003 and use that.
    I'll check it & see what's happening

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1