Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-03-10
3
Medium Priority
?
775 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

618 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