SUB&NBSP;GENEQ () if selection.start <> selection.end then Dim objRange As Range Dim objEq As OMath Set objRange = Selection.Range ' cannot add the following line of commented out code, otherwise the following flexible font controls will not be implemented in the Japanese version word 2007 and 2010 ' objrange.text = selection.range.text set Objrange = objrange.omaths.add (objrange) ' flexible control of what type of word multibyte italic For i = 1 To objrange.characters.count if Objrange.characters (i). text like "[A-za-z]" &NBsp then Objrange.characters (i). italic = true else objrange.characters ( i). Italic = false end if next i set objeq = objrange.omaths (1) objEq.BuildUp ' Add the following line of code, will make the Japanese version of word 2007 and 2010 normal behavior, or there will be the following strange phenomenon, Chinese version word 2013 there is no such phenomenon: ' in Word, enter x=3 in the first line, select x=3, use this function to generate a formula (X is italic, =3 is not italic), carriage return line , the current cursor will remain centered (for the same operation, the Chinese version word 2013 the cursor will stop at the left-aligned position), ' re-enter y=x+ 1, select Y=x+1, use this function to generate formulas (Y=x+1 are not italic) objEq.ParentOMath.Type = Wdomathinline end ifend sub
This article is from the "GONE with the Wind" blog, please be sure to keep this source http://h2appy.blog.51cto.com/609721/1604040
Considerations when you use VBA to automatically generate formulas in Word