Solved

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

Posted on 2014-03-10
3
734 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
[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: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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determine dependencies 3 21
Need help with a query 14 39
Need take combination of numbers out of the list 6 16
VBA to Update status Column based on recent date 20 41
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 …
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

726 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