Home > Software engineering >  Use VB6.0 by use the modified word macro code can realize the function of all replacement, but the e
Use VB6.0 by use the modified word macro code can realize the function of all replacement, but the e

Time:09-25

Use VB6.0 by use the modified word macro code can realize the function of all replacement, but the efficiency is too slow is what problem, or is there more efficiency way
Use macros are all in order to replace some of the key string, and then control table to add rows and add content to form
Wordapp. Selection. The Find. ClearFormatting
Wordapp. Selection. The Find. Replacement. ClearFormatting
For I=0 To UBound (Tzheng) Step 1
With wordapp. Selection. Find
Text=Tzheng (I)
. Replacement. Text=Nrong (I)
The Forward=True
'Wrap=wdFindAsk
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
StatusBar1. Panels (4). The Text=I & amp; "-" & amp; Tzheng (I) & amp; ":" & amp; Nrong (I)
Word itself USES the same written with VB macro velocity is seconds using a modified macro code is minutes and 10 minutes...
What is this why?

I have another method to compare all faster replacement but stability is not very good error-prone
Dim MyWord As Word. Application
Dim MyWordBook As Word. The Document
The Set MyWord=CreateObject (" Word. Application ")

The Do While MyWordBook. Content. The Find. The Execute (" should be replaced the contents of the ")
With MyWordBook. Content
If. The Find. The Execute (" should be replaced the contents of the ") Then
. The content of the Text=replace
End the If
End With
Loop
And the method of using after I don't how to control charts and add content to form

Hope you discuss with each other and see what better way to efficiency, faster way to

CodePudding user response:

Fyi:
 Application. ScreenUpdating=False 
Application. The Interactive=False

CodePudding user response:

reference 1st floor zhao4zhong1 response:
are for reference only:
 Application. ScreenUpdating=False 
Application. The Interactive=False


Tried no effect just don't know why the same code in the word macro execution is much faster than in the VB program execution

Is the difference between plane and tractors

CodePudding user response:

You try direct call macros in Word,

CodePudding user response:

Close the anti-virus software of real-time protection?
  •  Tags:  
  • VBA
  • Related