Solved

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

Posted on 2014-03-10
3
704 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:murbro
  • 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:murbro
ID: 39917035
Hi. Thanks but I am looking specifically to add a pic from my project resources
0
 

Author Closing Comment

by:murbro
ID: 39919854
thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
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 …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now