HomeExcelExcel Macro To Insert Picture in Comment Box

Excel Macro To Insert Picture in Comment Box

5/5 - (1 vote)

Excel Macro To Insert Picture in Comment Box

Excel में Picture को Comment Popup (Note) के अंदर Insert करने की प्रक्रिया को Macro Recorder से पूरी तरह रिकॉर्ड नहीं किया जा सकता, क्योंकि Format Comment → Fill Effects → Picture वाला डायलॉग VBA Macro Recorder द्वारा रिकॉर्ड नहीं होता।

Excel Macro To Insert Picture in Comment Box Pradip VedantSri
Excel Macro To Insert Picture in Comment Box Pradip VedantSri

इसलिए आपको VBA Macro का उपयोग करना होगा।

नीचे एक Macro दिया गया है जो:

  • Selected Cell में Comment/Note बनाएगा
  • Comment के Background में Picture लगाएगा
  • Comment Size को 1.35″ × 1.15″ सेट करेगा
  • Mouse Hover करने पर Picture Popup दिखेगी
Sub InsertPictureInComment()

    Dim PicPath As String
    Dim Cmt As Comment

    'Picture Select
    PicPath = Application.GetOpenFilename( _
              "Image Files (*.jpg;*.jpeg;*.png;*.bmp),*.jpg;*.jpeg;*.png;*.bmp")

    If PicPath = "False" Then Exit Sub

    'Delete Existing Comment
    On Error Resume Next
    ActiveCell.Comment.Delete
    On Error GoTo 0

    'Create New Comment
    ActiveCell.AddComment ""

    Set Cmt = ActiveCell.Comment

    'Insert Picture in Comment Background
    Cmt.Shape.Fill.UserPicture PicPath

    'Size (1.35" x 1.15")
    Cmt.Shape.Width = 1.35 * 72
    Cmt.Shape.Height = 1.15 * 72

    'Hide Comment
    Cmt.Visible = False

    MsgBox "Picture Comment Created Successfully"

End Sub

Macro चलाने का तरीका at Excel Macro To Insert Picture in Comment Box

  1. Alt + F11
  2. Insert > Module
  3. ऊपर का Code Paste करें
  4. Excel में वापस आएँ
  5. जिस Cell में Picture Comment चाहिए उसे Select करें
  6. Alt + F8
  7. InsertPictureInComment
  8. Run
  9. Picture Select करें

यदि आपका उद्देश्य Macro Recorder Recording Steps बनाना है (Training Video या Practical Exam के लिए), तो Recorder में केवल निम्न Steps रिकॉर्ड होंगे:

  1. Select Cell
  2. Shift + F2
  3. Comment Delete
  4. Esc
  5. Stop Recording

बाकी Format Comment → Picture Insert वाले Steps Recorder Capture नहीं करेगा, इसलिए उसके लिए VBA Code आवश्यक है।

VedantSri Sessional Reward Ceremony Toppers Students Image
VedantSri Sessional Reward Ceremony Toppers Students
3,536FansLike
11,855FollowersFollow
475FollowersFollow
94,100SubscribersSubscribe