Hello
When I develop a program for the end user, they do not have access to the WP_Tools and WP_Reporter code to create a table as is done in the WP_Reporter calc demo. If the end user is to create a table that performs calculations, they need to be able to assign paragraph names and commands after the table has been created.
The code at the bottom of this post is executed from a button.OnClick event and will assign a paragraph name and command to individual cells. I can confirm that the changes to the cells are made by displaying the paragraph name and formula by setting WPRichText1.ViewOptions := [wpShowParCalcNames,wpShowParCalcCommands]
Problems:
There are two issues that are present after assigning paragraph names and commands to the cells of a table to reproduce the WP_Reporter invoice demo.
a) The text in the cells to which commands have been assigned can be manually changed. This should not occure and does not in the WP_Reporter invoice demo cells.
b) If WPRichText1.RecalcText(true,true); is executed from a separate button.OnClick event, the recalculation is not performed.
Suggestions as to what I am missing?
TIA
John
Code to assign cell name and command is below
procedure TformWordProcessor.WPToolButtonDefineParagraphClick(Sender: TObject);
var
tempPar: TParagraph;
begin
if WPRichText1.CheckHasBody = True then
begin
WPRichText1.BeginUpdate; // Temporarily disable protection!
LMDInputDlg1.Width := 400;
LMDInputDlg1.CaptionTitle := 'Input Paragraph Name';
LMDInputDlg1.DefaultValue := '';
if LMDInputDlg1.Execute = True then
begin
if LMDInputDlg1.Value <> '' then
begin
WPRichText1.ActivePar.WPATName := LMDInputDlg1.Value;
WPRichText1.ActivePar.WPATName := LMDInputDlg1.Value;
tempPar := WPRichText1.ActivePar;
LMDInputDlg1.CaptionTitle := 'Input Paragraph Command';
LMDInputDlg1.DefaultValue := '';
if LMDInputDlg1.Execute = True then
begin
if LMDInputDlg1.Value <> '' then
begin
tempPar.ASetStringProp(WPAT_PAR_COMMAND, LMDInputDlg1.Value);
end;
end;
tempPar.ASet(WPAT_ParProtected,1);
end;
end;
WPRichText1.EndUpdate; // Enable protection!
WPRichText1.Modified := True;
end;
end;
Alles anzeigen