If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Defining the location a comment shows

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-15-07, 15:36
Jay59 Jay59 is offline
Registered User
 
Join Date: Sep 2006
Posts: 162
Defining the location a comment shows

I have a code that adds comments and fill with pics.

Is it possible to define the location the comment will show when you mouse over. I know you can move around the comment box once it appers.

The code I use is

Quote:
Sub Macro()

Dim rng As Range
Dim shp As Comment


Set rng = ActiveCell

If ActiveCell.Value = "Click to add pic" Then

Dim fn
fn = Application.GetOpenFilename
If fn = False Then
Else
Set shp = rng.AddComment("")
shp.Shape.Fill.UserPicture fn
shp.Shape.Height = 322
shp.Shape.Width = 465
ActiveCell = "QC Pic"
End If


Else
End If


End Sub
Reply With Quote
  #2 (permalink)  
Old 05-04-07, 19:32
JerryDal JerryDal is offline
Registered User
 
Join Date: Jan 2002
Location: Bay Area
Posts: 473
This is how I add comments automatically to a range of cells. You need to have the data for the comments stored in a worksheet where you can read them. In my case, the comment text is in Sheets(2) in the same column and cells where they will be added to Sheet1. I test for text in column A on Sheet1 and stop adding comments when a blank cell in encountered, which in my application is the end of the data.

Code:
Range("A2").Select
    While Trim(ActiveCell.Value) <> ""
        Range(ActiveCell.Address).AddComment
        Range(ActiveCell.Address).Comment.Visible = False
        Range(ActiveCell.Address).Comment.Text _
            Text:=Sheets(2).Cells(ActiveCell.Row, ActiveCell.Column + 1).Value & ""
        ActiveCell.Offset(1, 0).Select
    Wend
Next I set properties of each comment to ensure they are not visible until the mouse is dragged over the cell, and resize the comments to reduce the size of the retangular comment box.

HTML Code:
Dim c As Comment
For Each c In ActiveSheet.Comments
        c.Visible = False
        c.Shape.Locked = False
        c.Shape.TextFrame.AutoSize = True
    Next c
I hope this helps in what you are doing.
Good luck!
Jerry
Reply With Quote
  #3 (permalink)  
Old 05-04-07, 19:36
JerryDal JerryDal is offline
Registered User
 
Join Date: Jan 2002
Location: Bay Area
Posts: 473
A correction--the comment text I add is actually text that is in column B of Sheets(2), which happens to be a name for a code in column A.
Jerry
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On