Vundra
02-07-2017, 10:36 AM
I've written these two simple macros:
Sub SaveValues()
Dim cmtFontStrikethrough As Boolean
Dim cmtFontSuperscript As Boolean
Dim cmtFontSubscript As Boolean
Dim cmtFontUnderline As Variant
Range("A1").AddComment
Range("A1").Comment.Text Text:="ABC"
Range("A1").Comment.Visible = True
Range("A1").Comment.Shape.Select True
With Selection
cmtFontName = .Characters.Font.Name
cmtFontStyle = .Characters.Font.FontStyle
cmtFontSize = .Characters.Font.Size
cmtFontUnderline = .Characters.Font.Underline
cmtFontStrikethrough = .Characters.Font.Strikethrough
cmtFontSuperscript = .Characters.Font.Superscript
cmtFontSubscript = .Characters.Font.Subscript
SaveSetting "Test", "Font", "1", cmtFontName
SaveSetting "Test", "Font", "2", cmtFontStyle
SaveSetting "Test", "Font", "3", cmtFontSize
SaveSetting "Test", "Font", "4", cmtFontStrikethrough
SaveSetting "Test", "Font", "5", cmtFontSuperscript
SaveSetting "Test", "Font", "6", cmtFontSubscript
SaveSetting "Test", "Font", "7", cmtFontUnderline
End With
End Sub
Sub GetValues()
Range("A7").AddComment
Range("A7").Comment.Text Text:="ABC"
Range("A7").Comment.Visible = True
Range("A7").Comment.Shape.Select True
With Range("A7").Comment.Shape.TextFrame.Characters.Font
.Name = GetSetting("Test", "Font", "1")
.FontStyle = GetSetting("Test", "Font", "2")
.Size = GetSetting("Test", "Font", "3")
' .Strikethrough = GetSetting("Test", "Font", "4") 'Don't work!
' .Superscript = GetSetting("Test", "Font", "5") 'Don't work!
' .Subscript = GetSetting("Test", "Font", "6") 'Don't work!
' .Underline = GetSetting("Test", "Font", "7") 'Don't work!
End With
End Sub
I've noticed these facts into the registry:
1) for Strikethrough, Superscript, Subscript I find "Falso" (italian) and not "False"; if I convert manually these registry values in "False" the routine works fine
2) for Underline I find "-4142" (no underline) ; the problem is the inverted commas (that I cannot remove) because if change the code line in .Underline =-4142 the routine works
There is a way to solve these issues in Excel 2007? :(
Sub SaveValues()
Dim cmtFontStrikethrough As Boolean
Dim cmtFontSuperscript As Boolean
Dim cmtFontSubscript As Boolean
Dim cmtFontUnderline As Variant
Range("A1").AddComment
Range("A1").Comment.Text Text:="ABC"
Range("A1").Comment.Visible = True
Range("A1").Comment.Shape.Select True
With Selection
cmtFontName = .Characters.Font.Name
cmtFontStyle = .Characters.Font.FontStyle
cmtFontSize = .Characters.Font.Size
cmtFontUnderline = .Characters.Font.Underline
cmtFontStrikethrough = .Characters.Font.Strikethrough
cmtFontSuperscript = .Characters.Font.Superscript
cmtFontSubscript = .Characters.Font.Subscript
SaveSetting "Test", "Font", "1", cmtFontName
SaveSetting "Test", "Font", "2", cmtFontStyle
SaveSetting "Test", "Font", "3", cmtFontSize
SaveSetting "Test", "Font", "4", cmtFontStrikethrough
SaveSetting "Test", "Font", "5", cmtFontSuperscript
SaveSetting "Test", "Font", "6", cmtFontSubscript
SaveSetting "Test", "Font", "7", cmtFontUnderline
End With
End Sub
Sub GetValues()
Range("A7").AddComment
Range("A7").Comment.Text Text:="ABC"
Range("A7").Comment.Visible = True
Range("A7").Comment.Shape.Select True
With Range("A7").Comment.Shape.TextFrame.Characters.Font
.Name = GetSetting("Test", "Font", "1")
.FontStyle = GetSetting("Test", "Font", "2")
.Size = GetSetting("Test", "Font", "3")
' .Strikethrough = GetSetting("Test", "Font", "4") 'Don't work!
' .Superscript = GetSetting("Test", "Font", "5") 'Don't work!
' .Subscript = GetSetting("Test", "Font", "6") 'Don't work!
' .Underline = GetSetting("Test", "Font", "7") 'Don't work!
End With
End Sub
I've noticed these facts into the registry:
1) for Strikethrough, Superscript, Subscript I find "Falso" (italian) and not "False"; if I convert manually these registry values in "False" the routine works fine
2) for Underline I find "-4142" (no underline) ; the problem is the inverted commas (that I cannot remove) because if change the code line in .Underline =-4142 the routine works
There is a way to solve these issues in Excel 2007? :(