Excel Comments - can't change author name

Add-in Express™ Support Service
That's what is more important than anything else

Excel Comments - can't change author name
 
Nicholas Glasier


Guest


Hi,
Using Add-in-Express VCL with Delphi 7 pro.

Trying to change the authors name for a comment and I'm getting a compiler error telling me that this is a read only property.

The code is as follows:

for i := 1 to ExcelApp.ActiveWorkbook.Sheets.Count do
begin
intf := ExcelApp.ActiveWorkbook.Sheets[i];
intf.QueryInterface(Excel2000._Worksheet,IWks);
for j := 1 to IWks.Comments.Count do
begin
IWks.Comments.Item(j).Author := NewAuthor; <----- THIS LINE

IWks.Comments.Item(j).Text(newText, EmptyParam, EmptyParam);
end;
end;

Changing the comment text is no problem, and I found info about Excel on Experts Exchange that says it is possible to change the authors name.

Any ideas?

TIA Nick
Posted 07 Jul, 2006 05:36:14 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Nick,

The Author property is read-only in the Excel Object Model.

Changing the comment text is no problem, and I found info about Excel on Experts Exchange that says it is possible to change the authors name.


Could you please give me a link to this info?

Posted 11 Jul, 2006 06:25:01 Top
Nicholas Glasier


Guest


Hi Dmitry,

Try this, although you may need to be a member to view it.

http://www.experts-exchange.com/Applications/MS_Office/Excel/Q_21048690.html?query=Excel+Comment+Author&topics=604

In this sample, they are altering the text which contains the authors name rather than the author property, so it's a fudge rather than a solution.

Using ExcelApp.ActiveCell.AddComment(MyText) I get a comment without an authors name at all. but if I use a memo or add line breaks programatically with #13#10 then I get little squares as well as the line break. Also the text is all in bold. I think I can solve the bold problem, but what can I use instead of #13#10 to get a line return with no visible characters.

Regards Nick
Posted 13 Jul, 2006 01:01:25 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Nick,

I think I can solve the bold problem, but what can I use instead of #13#10 to get a line return with no visible characters.


Single #10 character.

Posted 13 Jul, 2006 04:37:50 Top
Nicholas Glasier


Guest


Many thanks Dmitry, just what I needed.

At the moment Excel doesn't seem to be closing properly. The application disappeears from the Task Manager Application list, but there is still a process called EXCEL.EXE in the process list. It is caused my my addin as deregistering the addin stops the process from continuing after Excel is closed.

This problem has only just appeared, and was discovered when I found that I couldn't recompile the addin after testing it and then making some changes. The only changes I had made were to the comment text function using the following code

ExcelApp.ActiveCell.Comment.Shape.TextFrame.Characters(1, tpos).Font.Bold := false;

Do I need to be accessing this property a different way, and if so how?

TIA, Nick
Posted 13 Jul, 2006 05:55:41 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Nick,

Try to split this long code line into several parts.


IRange := ExcelApp.ActiveCell;
if Assigned(IRange) then
  try
    IComment := IRange.Comment;
    if Assigned(IComment) then
      try
        // etc.
      finally
        IComment := nil;
      end;
  finally
    IRange := nil;
  end;

Posted 13 Jul, 2006 10:03:15 Top
Nicholas Glasier


Guest


Tried that Dmitri, but Excel is still hanging around in memory after I close the application window.

In the adxCOMAddInModuleAddInBeginShutdown I'm writing to an inifile which is then freed,

And in the adxCOMAddInModuleAddInFinalize event I'm setting Excel event handlers (assigned in the adxCOMAddInModuleAddInInitialize event) to nil.

This is an older add-in and doesn't use the event component distributed with recent releases. But it has worked fine until recently.

The only other thing I can think of at the moment is Nortons Internet Security doing an antivirus check before Excel closes. However it does one whether the Add-in is registered or not, and it's only when the add-in is registered that I get this problem.

Regards Nick
Posted 14 Jul, 2006 04:22:46 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Nick,

Are you sure that exactly this line causes the problem? Try to temporary comment it out.

Posted 14 Jul, 2006 07:34:25 Top
Nicholas Glasier


Guest


Hi Dmitri,

I was never too sure if this was causing the problem, but I made the changes you suggested and it didn't fix the problem last night. Howver this morning when I came back to it for another look, everything worked Ok despite the fact that no further changes had ben made.

Furthermore Nortons suddenly started asking me to approve other applications access to the Internet although they have had that permission for some time. I'm left with the idea that Nortons was somehow interfering with the unloading of an addin, and that a new update installed automatically overnight has fixed this problem.

Anyway it's going now

Regards nick
Posted 15 Jul, 2006 02:41:54 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Nick,

Ok, thank you for the notification.

Posted 17 Jul, 2006 09:56:38 Top