Consulting

Results 1 to 10 of 10

Thread: Insert Images

  1. #1
    VBAX Newbie
    Joined
    Dec 2006
    Posts
    5
    Location

    Smile Insert Images

    I have a document with 5 textbox I like to insert different pictures in each box when the document open . I appreciate any help.

    Thaks

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    So insert the pictures into the textboxes. I am not understanding the problem. Or even if there is a problem.

    If there is a problem, please state what it is.

    If you are trying to do something with VBA, then post the code. If there is some problem with your code, please post your code and clearly state what the problem is, and where in the code it seems to be.

    Why are you trying to put the pictures in when the document is opened? Why do you not just put the pictures in?

  3. #3
    VBAX Newbie
    Joined
    Dec 2006
    Posts
    5
    Location

    Insert Images

    Thank you Garry
    I want to do it by VBA code and I am not very familiar with VBA for example how can I select a TextBox on VBA to insert a picture in it ?

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Do you mean you want a different set of pictures each time you use the file? Are these to be chosen at random, in sequence from a folder of picures or in some other way?
    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'

  5. #5
    VBAX Newbie
    Joined
    Dec 2006
    Posts
    5
    Location
    Yes each time that I open the document I like to Insert images that related to another application. I have code to chose images I just want to know how I select textbox in VBA to insert the image without changing the size of textbox
    Thanks

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Can you post the code that you have?
    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
    VBAX Newbie
    Joined
    Dec 2006
    Posts
    5
    Location

    Insert Images

    The Document is a mail merge document and has 4 textbox on that every time that the document open I want to put 4 different images display on these textboxes the path and the name of these images are located in file name c:\windows\Fileloc.LOC here is my code:

    [VBA]
    Private Sub Document_Open()
    GetImages
    End Sub

    Public Sub GetImages()
    On Error Resume Next
    Dim PatID As String
    Dim Path As String
    If Dir$("c:\windows\Fileloc.LOC") <> "" Then
    Close 1
    Open "c:\windows\Fileloc.LOC" For Input As #1
    Line Input #1, Path ' This is Image Path
    Line Input #1, PatID ' This is part of file name

    End If
    Close 1
    ' Here I need your help
    ' I want to put image on each textbox the name file are Path+PatID+”1.jpg”
    'and Path+PatId+”2.jpg” and so on
    End Sub
    [/VBA]

  8. #8
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Why textboxes?

    Do they contain other text?

    Quote Originally Posted by ajannt9
    ... to insert the image without changing the size of textbox
    What do you want to do if the images won't fit in the textboxes?
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  9. #9
    VBAX Newbie
    Joined
    Dec 2006
    Posts
    5
    Location
    I want to resaiz image to fit in the textbox

  10. #10
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Easier said than done, although it can be done.

    It may be better to use ActiveX Image controls, and play with the PictureSizeMode property.

    So I too ask, why textboxes?

Posting Permissions

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