+ Reply to Thread
Results 1 to 3 of 3

Insert images into a comment

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-18-2006
    Posts
    135

    Insert images into a comment

    Hi,

    I have the following code that inserts images into a comment. It has always worked fine for me until I upgraded from office 2000 to 2003. Using office 2003 the code crashes on "ch.Chart.Export sFile". Does anyone have any idea why? Am i missing an add in or something?


    Sub PictureIntoComment()
    Dim ch As ChartObject
    Dim dWidth As Double
    Dim dHeight As Double
    Dim ws As Worksheet
    Dim sName As String
    Dim cmt As Comment
    Dim sPath As String
    Dim sFile As String
    Dim rng As Range
    Set ws = ActiveSheet
    Set rng = ActiveCell
    sPath = ThisWorkbook.Path & "\"
    If sName = "" Then sName = "0"
    sFile = sPath & sName & ".jpeg"
    
        dWidth = Selection.Width
        dHeight = Selection.Height
        Selection.Cut
        Set ch = ws.ChartObjects.Add(Left:=rng.Left, Top:=rng.Top, _
          Width:=dWidth, Height:=dHeight)
        ch.Chart.Paste
        rng.Activate
        ch.Chart.Export sFile
        ch.Delete
        Set cmt = rng.AddComment
        cmt.Text Text:=""
        With cmt.Shape
          .Fill.UserPicture sFile
          .Width = dWidth
          .Height = dHeight
        End With
    End Sub

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    The code runs fine in Excel 2003 so it should work in
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    04-18-2006
    Posts
    135
    Can you tell me what references you are using in VBAProject?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1