Solved

VB.net Excel Add-in Add a picture to a cell from resources

Posted on 2014-03-10
3
746 Views
Last Modified: 2014-03-11
Hi

How do I call the following code to insert an image from Resouces. oPicPath is the file path. What would I set this to? I am also getting the error "msoTrue is not declared"


    Sub Add_Pic_To_Cell(ByVal oRow As Long, ByVal oColumn As Integer, ByVal oPicPath As String)
        With Globals.ThisAddIn.Application.ActiveSheet.Pictures.Insert(oPicPath)
            With .ShapeRange
                .LockAspectRatio = msoTrue
                .Width = 75
                .Height = 100
            End With
            .Left = Globals.ThisAddIn.Application.ActiveSheet.Cells(oRow, oRow).Left
            .Top = Globals.ThisAddIn.Application.ActiveSheet.Cells(oRow, oRow).Top
            .Placement = 1
            .PrintObject = True
        End With
    End Sub
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 39916980
I tried this simple macro and working fine for me

Sub Macro1()
'
' Macro1 Macro
'
Dim oRow As Long
Dim oColumn As Integer
Dim oPicPath As String
oRow = 1
oColumn = 1
oPicPath = "C:\PA_ERROR.jpg"


 With ActiveSheet.Pictures.Insert(oPicPath)
            With .ShapeRange
                .LockAspectRatio = msoTrue
                .Width = 75
                .Height = 100
            End With
            .Left = ActiveSheet.Cells(oRow, oRow).Left
            .Top = ActiveSheet.Cells(oRow, oRow).Top
            .Placement = 1
            .PrintObject = True
        End With
'
End Sub

Open in new window

0
 

Author Comment

by:Murray Brown
ID: 39917035
Hi. Thanks but I am looking specifically to add a pic from my project resources
0
 

Author Closing Comment

by:Murray Brown
ID: 39919854
thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question