Perhaps we're talking differnt things:
I talk about excel recording macros to see how a comment is added to some cell in VBA Code, not to put the comment text as an excel macro.
I just opened Excel2003, go to Menu:Extras, Macros, record macro, then did add a comment to some Cell F9 and then stopped macro recording via Menu: Extras, Macro, stop recording. (Menu items may differ in english, I'm translating from german)
This is the code I got in the excel Macros section:
Code:
Sub Makro1()
Workbooks.Add
Range("F9").AddComment
Range("F9").Comment.Visible = False
Range("F9").Comment.Text Text:="username:" & Chr(10) & "test"
End Sub
The result of your macro recording may differ, depending on what you do in excel. The point is: You don't need to code it, you just do whatecer you're used to do in excel, and excel shows you the VBA code needed to repeat your manual actions with macro code.
Now this helps me to now what to do in code and generalize this into code adding a comment to any cell with foxpro:
Code:
* first the unavoidable creation of an excel application object:
oExcel = CreateObejct("Excel.Application")
* and a new workbook, as the macro does:
oExcel.Workbooks.Add()
* Now first create a range object as used in the recorded macro:
oRange = oExcel.Workbooks(1).Sheets(1).Range("F9")
* now we can continue as in the recorded macro:
oRange.AddComment()
oRange.Comment.Text("test")
* take a look at the result:
oExcel.visible = .t.
You could also call the recorded macro to do it's stuff instead of translating the code to VFP syntax. Depends on what you want.
Translating VBA to VFP is some experience, there is no one fits all recipe, but you'll see once you've done one or two programs. In VBA macros something like Range("F9") falls from the sky, to do the same in VFP you first need a Range object. Those are the things you need experience to know, also in VBA a call to a method Text is using a parameter syntax like TEXT='...', in VFP you need to pass parameters via method(parameter1,parameter2,...), you can lookup in the VBA help, that Text is the first parameter of the Text method, the full definition is declared in the description of Comment Objects, it's Comment.Text(Text, Start, Overwrite).
Bye, Olaf.