Home > Back-end >  How to call the word bookmarks, generated a report? Consulted.
How to call the word bookmarks, generated a report? Consulted.

Time:10-08

Consult everybody warrior, about Delphi call word bookmarks,
The report is generated by word bookmarks
Now I have a template, bookmarks I have done, can also generate a report,
But my request is that according to the situation of the database, generate report, and it is generated in the same word,,
Excuse me?

If (Application) MessageBox (' are you sure you want to generate the report document? ', 'prompt', MB_OKCANCEL)=IDOK) then
The begin
Wordapp:=CreateOLEObject (' Word. Application);
Wordapp. Visible:=true;
If Opendialog1. Execute then
FileName:=Opendialog1. FileName;//'f: \ a. d. ot;

Wordapp. Documents. The add (FileName, False);
Wordapp. Documents. The Item (1). Bookmarks. Item (" name_1 "). The Range, the Text:='test';
Wordapp. Documents. The Item (1). Bookmarks. Item (' no_1) Range. Text:='1111';
Wordapp. Documents. The Item (1). Bookmarks. Item (' firstName_1) Range. Text:='S'.
Wordapp. Documents. The Item (1). Bookmarks. Item (' LastName_1) Range. Text:='H';
Wordapp. Documents. The Item (1). Bookmarks. Item (" age "). The Range, the Text:='1';

Wordapp. Documents. The Item (1). Saveas (' report1. Doc);
end;

CodePudding user response:

Now that you know that generate a is Item (1)
I will not say so much

CodePudding user response:

Sorry, I also copy to this code, for here the item (1) what is the meaning I don't know,
Read your reply, I added a:

Wordapp. Documents. The Item (2). Bookmarks. Item (" name_1 "). The Range, the Text:='test';

But the execution times wrong, say "set the required member does not exist"

Please let us know! Thank you very much!!!!!!!!!!!!!!!

CodePudding user response:

Wordapp. Documents. Item. Add?

CodePudding user response:

Wordapp. Documents. Item. Add (name, range)
The name book signature string
Range is indicated by the selected content your bookmarks in word place for Selection. The range

CodePudding user response:

Hello!!!!! Can you instruct me how to write? It took me a day to look at the word operation, dizzy also didn't find a way,
Thank you very much!!!!!

CodePudding user response:

I'm sorry I dialed the wrong number on the 4th floor, used on the first floor but you should watch out
If you write by this not line, say to my study

Bookmark is to specify a location range to add a bookmark name
Wordapp. Documents. The Item (1). The Bookmarks. Item. Add (name, range)
So you add multiple bookmarks difficulty is to find where to add the range

CodePudding user response:

I may not be clear,
I now use the word problems is completes the templates, to replace with the word bookmarks,
Then use Delphi to the bookmarks corresponding location assignment, complete, but to generate a report is not only one or two copies of variable number, and I can't write a long templates,
So my solution is based on data rate cycle template, replace the data, insert into the target word file, print,
Repeated problems is how to get the template and insert the same target word,

CodePudding user response:

Express some confusion ask people should seize technology points where not is not the case with the logical

You should be want to word, insert the report, have a certain format requirements, cannot be directly inserted,
You can't arrange for all bookmarks,

If this is the case 1, you can become how to insert content at the location word 2, why do you want to use bookmarks?
{1. Using a keyword search to locate
Heading level 2, the directory structure such as positioning
I have a word resources API you should have seen it or couldn't write the bookmarks I have with the word is the same as the WPS, resources inside word API is good search
}
The else
{I can't provide advice}
  • Related