Home > Software engineering >  VB generated word tables without border lines? There are a few small problems
VB generated word tables without border lines? There are a few small problems

Time:10-05

1, the word document, insert a table, but there is no border lines, how to set? The code is as follows:

Dim MyWord As Word. Application 'Word Application objects
Dim MyDocument As Word. The Document 'open Document object
Dim MyRange As Word. Range 'position within the document

Dim MySelect As Word. Selection 'documents within the selected content
Dim MyTable As Word. Table 'in a document form


The Set MyWord=CreateObject (" Word. Application ") 'create Word object
MyWord. Visible=True 'let the document displays
The Set MyDocument=MyWord. Documents. Add 'new word document
The Set MyRange=MyDocument. Range (Start:=0, End:=0) 'Set the cursor in the first line of the first

'add a form in Word, line 4, four columns
The Set MyTable=MyWord. ActiveDocument. Tables. The Add (MyWord. Selection. Range, 4, 4)

For I=1 To 4
For j=1 To 4
'MyTable. Cell (I, j) Range. InsertAfter "4"
If iCount Mod 4=1 Then
OCell. Range. InsertAfter "first" & amp; (iCount - 1)/4 + 1 & amp; "Line", "
End the If
MyTable. Cell (I, j) Range. InsertAfter "23"
Next j
Next I

MyDocument. Activate MyWord. 'let document is active' Activate 'for same document is active
MyWord. Visible=True 'let the document displays

The Set MyWord=Nothing
The Set MyDocument=Nothing

2, MyTable. Cell (1, 3). The Range, InsertAfter "hello"
How can you replace the original cell content? The clear content and then insert content?

3, how to set up the insert cell content of font, size, color, center and other format?

CodePudding user response:

http://bbs.csdn.net/topics/50473889

CodePudding user response:

First record macros in the WORD, and then add the macro code to your VB program

CodePudding user response:

How do I record macro? After recording, how to check the generated code? Trouble the detailed steps cough up, thank you!
Or a unit which directly tell me set the table font, bold, color, center the basic format of operation

CodePudding user response:

In the Word 2003 "tools, macro, record a new macro" start recording macros, manual complete the required function, "by the end of macro button" stop recording macros, press Alt + F11 key, check just record macro corresponding VBA code,
  • Related