PDA

View Full Version : Inserting pictures (bmps) from Macros into location of current cell (variable cell)



SteveM99
12-03-2015, 08:16 AM
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

Kenneth Hobs
12-03-2015, 06:19 PM
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

SteveM99
12-04-2015, 06:41 AM
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

Kenneth Hobs
12-04-2015, 12:43 PM
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.