PDA

View Full Version : [SOLVED:] VBA to Print the Comments of a single cell



simora
07-30-2021, 12:05 AM
I am trying to print the Comments of a single cell.
Also, Is there a way to copy it to another sheet and print it from there.
It would seem to be a shape at that point.
I tried the latter, but the shape does not allow you to copy it.

This bit works


Range("AE9").Select
ActiveCell.Comment.Visible = True
Range("AE9").Comment.Shape.Select True


But this bit DOES NOT WORK


Selection.Copy
Sheets("Sheet2").Range("A1").Paste

arnelgp
07-30-2021, 05:45 AM
Range("AE9).Select
Selection.Copy
Sheets("Shee2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteComments, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

simora
07-30-2021, 04:27 PM
arnelgp: Hi Thanks.

I can copy the Comments to the other sheet; The problem is that when I try to print, the error says:
" Excel did not find anything to print "

This code does show the comments, but I cant figure out how to print them.



Sub CopyComments()
ActiveSheet.Range("AE9").Select
ActiveSheet.Range("AE9").Comment.Visible = True
Selection.Copy

Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteComments, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

End Sub


How can I copy the text from a single cells' comments ?

simora
07-30-2021, 07:04 PM
This will get the Comments of a single cell for printing. It's NOT Text, but an image.



Sub CopyACellComments()

ActiveSheet.Range("AE9").Select
ActiveSheet.Range("AE9").Comment.Visible = True
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteComments, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False


With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup

.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintInPlace
.PrintQuality = 600
.PrintErrors = xlPrintErrorsDisplayed
.FirstPage.RightFooter.Text = ""
End With
ActiveWindow.SelectedSheets.PrintPreview
End Sub


If there's a way to get comments from a single cell as Text, I'll like to know.

p45cal
07-31-2021, 04:39 AM
try:
Sheets("Sheet2").Range("A1").Value = Sheets("Sheet1").Range("AE9").Comment.TextNow print Sheet2 normally.

simora
08-05-2021, 01:28 AM
p45cal: THANKS !

That works great.