+ Reply to Thread
Results 1 to 3 of 3

help please (VBA to insert images)

  1. #1
    alenhart
    Guest

    help please (VBA to insert images)

    through my searching of this and other boards, I came up with the
    following code that would pick up the file name in E4 and insert the
    image in E5 and then loop through the worksheet. It works perfectly the
    first time, but then it seems to get stuck and repeat itself over and
    over with out end. obviously I am missing something.

    please help!


    here is the code:

    Sub InsertImages()
    Dim i As Integer
    Dim sFilename As String
    Dim bcontinue As Boolean
    Dim spath As String

    spath = "http://cmspro/stellent/idcplg/webdav/Contribution
    Folders/Exhibitions_Public/Fast Forward/FFImages/"
    bcontinue = True
    While bcontinue
    sFilename = Worksheets(2).Cells(4, 5).Value
    If sFilename = "" Then
    bcontinue = False
    Else
    Cells(4, 6).Select
    ActiveSheet.Pictures.Insert(spath + sFilename).Select
    Selection.ShapeRange.LockAspectRatio = msoTrue
    Selection.ShapeRange.Height = 85
    i = i + 1
    End If
    Wend
    End Sub


  2. #2
    Tim Williams
    Guest

    Re: help please (VBA to insert images)

    Where's the next filename after E4?
    You're incrementing i but not using it anywhere, so it's not easy to see what it's *supposed* to do...

    Tim

    "alenhart" <[email protected]> wrote in message news:[email protected]...
    > through my searching of this and other boards, I came up with the
    > following code that would pick up the file name in E4 and insert the
    > image in E5 and then loop through the worksheet. It works perfectly the
    > first time, but then it seems to get stuck and repeat itself over and
    > over with out end. obviously I am missing something.
    >
    > please help!
    >
    >
    > here is the code:
    >
    > Sub InsertImages()
    > Dim i As Integer
    > Dim sFilename As String
    > Dim bcontinue As Boolean
    > Dim spath As String
    >
    > spath = "http://cmspro/stellent/idcplg/webdav/Contribution
    > Folders/Exhibitions_Public/Fast Forward/FFImages/"
    > bcontinue = True
    > While bcontinue
    > sFilename = Worksheets(2).Cells(4, 5).Value
    > If sFilename = "" Then
    > bcontinue = False
    > Else
    > Cells(4, 6).Select
    > ActiveSheet.Pictures.Insert(spath + sFilename).Select
    > Selection.ShapeRange.LockAspectRatio = msoTrue
    > Selection.ShapeRange.Height = 85
    > i = i + 1
    > End If
    > Wend
    > End Sub
    >




  3. #3
    Jim Cone
    Guest

    Re: help please (VBA to insert images)

    You are not very talkative are you?
    I think this is what you want.
    --
    Jim Cone
    San Francisco, USA
    http://www.realezsites.com/bus/primitivesoftware

    Sub InsertImages()
    Dim sFilename As String
    Dim spath As String
    Dim bcontinue As Boolean
    Dim rngCell As Excel.Range

    spath = "http://cmspro/stellent/idcplg/webdav/Contribution " & _
    "Folders/Exhibitions_Public/Fast Forward/FFImages/"
    bcontinue = True
    Set rngCell = Worksheets(2).Cells(4, 5)
    While bcontinue
    sFilename = rngCell.Value
    If sFilename = "" Then
    bcontinue = False
    Else
    'In the column to the right
    rngCell.Offset(0, 1).Select
    ActiveSheet.Pictures.Insert(spath + sFilename).Select
    Selection.ShapeRange.LockAspectRatio = msoTrue
    Selection.ShapeRange.Height = 85
    'Pick the cell directly below and do it again.
    Set rngCell = rngCell.Offset(1, 0)
    End If
    Wend
    Set rngCell = Nothing
    End Sub
    '--------------


    "alenhart" <[email protected]>
    wrote in message
    through my searching of this and other boards, I came up with the
    following code that would pick up the file name in E4 and insert the
    image in E5 and then loop through the worksheet. It works perfectly the
    first time, but then it seems to get stuck and repeat itself over and
    over with out end. obviously I am missing something.
    please help!
    here is the code:

    Sub InsertImages()
    Dim i As Integer
    Dim sFilename As String
    Dim bcontinue As Boolean
    Dim spath As String

    spath = "http://cmspro/stellent/idcplg/webdav/Contribution
    Folders/Exhibitions_Public/Fast Forward/FFImages/"
    bcontinue = True
    While bcontinue
    sFilename = Worksheets(2).Cells(4, 5).Value
    If sFilename = "" Then
    bcontinue = False
    Else
    Cells(4, 6).Select
    ActiveSheet.Pictures.Insert(spath + sFilename).Select
    Selection.ShapeRange.LockAspectRatio = msoTrue
    Selection.ShapeRange.Height = 85
    i = i + 1
    End If
    Wend
    End Sub


+ 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