Results 1 to 5 of 5

Managing pictures in excel

Threaded View

impala096 Managing pictures in excel 03-24-2023, 12:27 PM
impala096 Re: Managing pictures in excel 03-24-2023, 01:58 PM
FlameRetired Re: Managing pictures in excel 03-24-2023, 03:37 PM
impala096 Re: Managing pictures in excel 03-24-2023, 04:05 PM
impala096 Re: Managing pictures in excel 03-27-2023, 03:01 PM
  1. #1
    Forum Contributor
    Join Date
    10-14-2007
    MS-Off Ver
    Excel 2021
    Posts
    121

    Managing pictures in excel

    I setup a spreadsheet to track the biggest intraday gainers in the stock market. A screenshot of the biggest intraday gainers are stored in Column B but the chart is only displayed when a cell in Column B is selected. For instance in the first picture Cell C2 is selected so no picture is displayed but in the next picture B2 is selected so the chart for GNPX is displayed. I attached the code I used to get this desired functionality. I am very quickly able to switch between reviewing the intraday data and looking at the intraday chart.

    The problem is after 500 rows of data (and corresponding intraday charts) the spreadsheet is becoming sluggish when opening and saving. Is there a better way to manage all the pictures in the spreadsheet to keep it running snappy?

    Untitled3.png

    Untitled4.png


    Sub addpictest()
    
      Dim pic_file As String
      Dim pict_name As String
      Dim pict1 As Picture
     
      If ActiveCell.Comment Is Nothing Then ActiveCell.AddComment
      pic_file = Application.GetOpenFilename("PNG (*.PNG), *.PNG", Title:="Pls open a picture file:")
    
      Set pict1 = ActiveSheet.Pictures.Insert(pic_file)
      pict_name = pict1.Name
     
     
      On Error Resume Next
     
      With ActiveCell.Comment.Shape
       .Fill.Visible = msoTrue
       .Fill.ForeColor.RGB = RGB(255, 255, 255)
       .Fill.BackColor.SchemeColor = 80
       .Fill.UserPicture (pic_file)
       .Height = 725
       .Width = 1921
       
    Dim xComment As Comment
    
    For Each xComment In ActiveSheet.Comments
       xComment.Shape.Placement = xlMove
    Next
    
      End With
        
      pict1.Delete
      Set pict1 = Nothing
      ActiveCell.Comment.Visible = False
     
     
    End Sub
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
     'www.contextures.com/xlcomments03.html
     Dim rng As Range
     Dim cTop As Long
     Dim cWidth As Long
     Dim cmt As Comment
     Dim sh As Shape
    Application.DisplayCommentIndicator _
          = xlCommentIndicatorOnly
    Set rng = ActiveWindow.VisibleRange
    cTop = rng.Top + rng.Height / 2
    cWidth = rng.Left + rng.Width / 2
    If ActiveCell.Comment Is Nothing Then
      'do nothing
    Else
       Set cmt = ActiveCell.Comment
       Set sh = cmt.Shape
       sh.Top = cTop - sh.Height / 2
       sh.Left = cWidth - sh.Width / 2
       cmt.Visible = True
    End If
    End Sub
    Last edited by impala096; 03-24-2023 at 01:05 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Managing worksheets in excel
    By sunboy in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-24-2020, 02:34 AM
  2. Replies: 3
    Last Post: 01-19-2018, 09:17 AM
  3. How to remove hyperlink to pictures in excel and retain the pictures?
    By london7871 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-04-2016, 11:24 PM
  4. Managing expenses with excel
    By dmcky in forum Excel General
    Replies: 5
    Last Post: 11-30-2013, 05:51 PM
  5. PDF managing from Excel macro
    By DGL in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-19-2012, 11:14 AM
  6. Managing Excel from VB^
    By Uwe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2006, 02:45 PM
  7. [SOLVED] Excel's Compress Pictures or deleting pictures doesn't seem work
    By guidod in forum Excel General
    Replies: 1
    Last Post: 01-29-2006, 02:50 AM

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