Home > Software engineering >  There are multiple tables in VB6.0 by use of Word how to locate the specified form
There are multiple tables in VB6.0 by use of Word how to locate the specified form

Time:09-25

Key code is as follows:

 On Error Resume Next 'mistake to continue to the Next line of code 

The Set wordapp=New Word. Application instantiation
'Wordapp. Documents. Open the App. The Path & amp; "Data \ \ templates. Doc"
Wordapp. Visible=False 'display Office Word interface
Wordapp. DisplayAlerts=False 'don't prompt save dialog
Wordapp. Selection. The Find. ClearFormatting
Wordapp. Selection. The Find. Replacement. ClearFormatting
Wordapp. ActiveDocument. Tables (14). The Cell (2, 2) Range. InsertAfter "test results"
* on one line of code that is inserted to the cell specified form content *
With wordapp. Selection. Find
. The Text="" test", "
. Replacement. Text=""
The Forward=True
The Wrap=wdFindContinue
. The Format=False
The MatchCase=False
. MatchWholeWord=False
. MatchByte=True
. MatchWildcards=False
. MatchSoundsLike=False
. MatchAllWordForms=False
End With
Wordapp. Selection. The Find. Execute the Replace:=wdReplaceAll
MsgBox ActiveDocument. Tables. Total Count 'access to the file form
ActiveDocument. SaveAs "c: \ MyWord. Doc" the word 'save the last article

On the Error Resume Next
Wordapp. Quit
The Set wordapp=Nothing

MsgBox "generate success",, ""


I have a lot of tables in the word how do I locate one
The table in a table with 14 digital position I would do you have any other way
Prevention after word change will affect the form number for each table can have a title according to the above judgment and then positioning or what tag or what better way to give advice or comments please

CodePudding user response:

Start recording macros in the Word 2003, manual, complete the required function end record macros, press Alt + F11 key, check just record macro corresponding VBA code,

CodePudding user response:

I think on the top of the table is not actually have any name of the table, the table is set to the name of the bookmark, this is not the same as the table name, bookmarks content is different, testing the bookmarks, to locate the specific forms, is the form of the name should be the same, for example bookmark names are: name

CodePudding user response:

reference 1st floor zhao4zhong1 response:
start recording macros in the Word 2003, manual, complete the required function end record macros, press Alt + F11 key, check just record macro corresponding VBA code,


I will main problem is the location of this record macro problem because template is change so table sorting will become
I don't want to modify the software every time so I want to find a way to smart positioning or judging form the sort of number

CodePudding user response:

refer to the second floor u013249970 response:
I think on the top of the table is not actually have any name of the table, the table is set to the name of the bookmark, this is not the same as the table name, bookmarks content is different, testing the bookmarks, to locate the specific forms, is the form of the name should be the same, for example bookmark names are: name


You don't quite understand the meaning of the second half of the sentence bookmarks alternative content I will but give a instance bookmarks positioning can not study it? Thanks

CodePudding user response:

How do people judge (form, content, form, form line format, font format used in the form of each cell,... ), the code is how to determine,

CodePudding user response:

Before and after the table near the text content
.

CodePudding user response:

Later, at night to do a sample for you,
  • Related