Addin

  • Thread starter Thread starter Excel User
  • Start date Start date
E

Excel User

Hi,

I have a workbook that I have used as an addin, how do I refer to it to do
something

i.e. if I have an image in the workbook in sheet1 how do I copy this to the
active workbook?

Thanks for any help!
 
You can use it just like any other workbook (well, almost). But in this case,
it's true.

Option Explicit
Sub testme()

Dim myFromPict As Picture
Dim myToPict As Picture
Dim myAspectRatio As Double

Set myFromPict _
= Workbooks("book1.xla").Worksheets("Sheet1").Pictures("Picture 1")

myFromPict.Copy
With ActiveSheet
.Paste
Set myToPict = .Pictures(.Pictures.Count) 'last one added
With myToPict
myAspectRatio = .Width / .Height
End With
myToPict.ShapeRange.LockAspectRatio = msoTrue
myToPict.Left = .Range("A1").Left
myToPict.Top = .Range("A1").Top
myToPict.Height = .Range("a1:a5").Height
With myToPict
.Width = myAspectRatio * .Height
End With
End With
End Sub
 
Dave,

Cool - thanks for that !!

Regards,

Dave Peterson said:
You can use it just like any other workbook (well, almost). But in this
case,
it's true.

Option Explicit
Sub testme()

Dim myFromPict As Picture
Dim myToPict As Picture
Dim myAspectRatio As Double

Set myFromPict _
= Workbooks("book1.xla").Worksheets("Sheet1").Pictures("Picture 1")

myFromPict.Copy
With ActiveSheet
.Paste
Set myToPict = .Pictures(.Pictures.Count) 'last one added
With myToPict
myAspectRatio = .Width / .Height
End With
myToPict.ShapeRange.LockAspectRatio = msoTrue
myToPict.Left = .Range("A1").Left
myToPict.Top = .Range("A1").Top
myToPict.Height = .Range("a1:a5").Height
With myToPict
.Width = myAspectRatio * .Height
End With
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top