Consulting

Results 1 to 4 of 4

Thread: Inserting pictures (bmps) from Macros into location of current cell (variable cell)

  1. #1
    VBAX Regular
    Joined
    Dec 2015
    Posts
    57
    Location

    Inserting pictures (bmps) from Macros into location of current cell (variable cell)

    I have installed excel tickmarks as marcos getting the pictures from my start folder using excel 2007. I cannot figure out how to have the picture inserted exactly where I am in the spreadsheet at the time I am selecting to run the macro button. The picutres keep populating in an area around column b row 4 each time. In my excel 2013 on my other computer it works perfect where the pics are inserted exactly where I execute. I can't figure this out. The tickmarks and macros are originally by Mark & Carol Lehman and they are very useful for accounting purposes.

    Here is my vba text

    Sub boxes()
    '
    ' boxes Macro
    ' Macro recorded 2/27/2001 by Mark & Carol Lehman
    '
    '
    ActiveSheet.Pictures.Insert( _
    "C:\Users\stevem\AppData\Roaming\Microsoft\Excel\XLSTART\Symbols\boxes.bmp" ).Select
    End Sub

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum!

    Most complain that it does insert at the activecell.

    Sub Main()  
      Dim fn As String
      fn="C:\Users\stevem\AppData\Roaming\Microsoft\Excel\XLSTART\Symbols\boxes.bmp"
      With ActiveSheet.Pictures.Insert(fn)
        ActiveCell.Left = .TopLeftCell.Left
        ActiveCell.Top = .TopLeftCell.Top
      End With
    End Sub

  3. #3
    VBAX Regular
    Joined
    Dec 2015
    Posts
    57
    Location

    after changing macro did not work

    Quote Originally Posted by Kenneth Hobs View Post
    Welcome to the forum!

    Most complain that it does insert at the activecell.

    Sub Main()  
      Dim fn As String
      fn="C:\Users\stevem\AppData\Roaming\Microsoft\Excel\XLSTART\Symbols\boxes.bmp"
      With ActiveSheet.Pictures.Insert(fn)
        ActiveCell.Left = .TopLeftCell.Left
        ActiveCell.Top = .TopLeftCell.Top
      End With
    End Sub

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Does not work does not help me help you. Likely, your fn does not exist. One can and probably should do error checks to see if the path does exist. I can show you how if needed.

    Otherwise, I see no way to help as this worked for me as does the insert line alone. I very seldom post code that I have not tested.

    I normally move shapes after I have inserted them to some other cell rather than the activecell.

Posting Permissions

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