/ / ================== word_vba code ============================= // Sub inword () DIM MyTable As Table Dim MyBox, MyPict, Myshape As Shape 'Draws the first rectangular box set mybox = activeDocument.shapes.addTextBox (orientation: = 1, left: = 90, top: = 70, width: = 414, Height: = 200 ) 'Painting a vertical line set myline = activeDocument.shapes.addline (255, 70, 255, 270)
'Draw the first picture set mypict = activeDocument.shapes.addpicture ("d: /test/test/load_jpg1/Photo/108259.jpg", _ linktofile: = false, savewithdocument: = true, left: = 180, top: = 80, width: = 65, Height: = 80) 'Draw the second picture set mypict = activedocument.shapes.addpicture ("d: /test/test/load_jpg1/photo/108259.jpg", _ linktofile: = false Savewithdocument: = true, left: = 262, top: = 80, width: = 65, Height: = 80) 'Name set myshape = activeDocument.shapes.addtextBox (orientation: = 1, left: = 108, top: = 198, width: = 126, Height: = 18) myshape.line.visible = msofalse myshape.textFrame.TextRange.text = "Name: New help"
'Age Set myShape = ActiveDocument.Shapes.AddTextbox (Orientation: = 1, Left: = 108, Top: = 225, Width: = 126, Height: = 18) myShape.Line.Visible = msoFalse myShape.TextFrame.TextRange.Text = "Age: 12" 'Personal Information Set MyShape = ActiveDocument.Shapes.addTextBox (Orientation: = 1, Left: = 351, Top: = 90, Width: = 126, Height: = 99) myshape.visible = msofalse myshape.textFrame.TextRange.text = "Personal Information"
'Add text box form Set myShape = ActiveDocument.Shapes.AddTextbox (Orientation: = 1, Left: = 288, Top: = 198, Width: = 189, Height: = 63) myShape.Line.Visible = msoFalseSet myTable = ActiveDocument .Tables.Add (Range: = myShape.TextFrame.TextRange, NumRows: = 3, NumColumns: = _ 2, DefaultTableBehavior: = wdWord9TableBehavior, AutoFitBehavior: = wdAutoFitFixed) myTable.Cell (1, 1) .Range.Text = "weight "MyTable.cell (1, 2) .range.text =" 40kg "MyTable.cell (2, 1) .Range.text =" Height "MyTable.cell (2, 2) .Range.Text =" 120cm "MyTable .Cell (3, 1) .range.text = "Sit high" myTable.cell (3, 2) .Range.text = "65cm" end sub // ============== ==== Delphi code ======================================= ; begin SaveDialog1.InitialDir: = ExtractFilePath (Application.ExeName) 'out_file'; SaveDialog1.Execute; self.Refresh; filename: = savedialog1.FileName; if length (filename) = 0 then begin application.MessageBox ( 'not selected statistics The storage location of the file does not save statistics! ',' Prompt box ', MB_OK; E XIT; end; WordApp: = createoleObject ('word.application "; Wordapp.Visible: = true; WordDoc: = Wordapp.Documents.add; Try
/ / Draw the first rectangular box WordDoc.shapes.addTextBox (orientation: = 1, left: = 90, top: = 70, width: = 414, height: = 200); // draw a vertical line WordDoc.shapes. AddLine (255, 70, 255, 270); // Draw the first picture WordDoc.shapes.addpicture (applfilepath (Application.exename) 'Photo / 108259.jpg', linktofile: = false, savewithdocument: = true, left: = 180, top: = 80, width: = 65, height: = 80); // Draw the second picture WordDoc.shapes.addpicture (extractfilepath (application.exename) 'photo / 108259.jpg', linktofile: = false Savewithdocument: = true, left: = 262, top: = 80, width: = 65, Height: = 80);
// Select Name Box Wordshape: = WordDoc.shapes.addTextBox (Orientation: = 1, Left: = 108, Top: = 198, width: = 126, Height: = 18); Wordshape.Line.Visible: = false; Wordshape .TextFrame.TextRange.text: = 'Name: New help'; // age box Wordshape: = worddoc.shapes.addTextBox (orientation: = 1, left: = 108, top: = 225, width: = 126, Height: = 18); //. Select; Wordshape.Line.Visible: = false; Wordshape.TextFrame.TextRange.text: = 'Age: 12'; // Personal Information Box Wordshape: = WordDoc.shapes.addTextBox (orientation: = 1 , Left: = 351, TOP: = 90, Width: = 126, Height: = 99); //. Select; Wordshape.Line.Visible: = false; Wordshape.TextFrame.TextRange.Text: = 'Personal Information'; = WordDoc.shapes.addTextBox (orientation: = 1, Left: = 288, TOP: = 198, width: = 189, Height: = 63); //. Select; Wordshape.Line .Visible: = false; WordTable: = worddoc.Tables.Add (Range: = wordShape.TextFrame.TextRange, NumRows: = 3, NumColumns: = 2, DefaultTableBehavior: = wdWord9TableBehavior, AutoFitBehavior: = wdAutoFitFixed); WordTable.Cell (1 1) .range.text: = 'weight'; WordTable.cell (1, 2) .ra Nge.Text: = '40kg'; WordTable.cell (2, 1) .range.text: = 'Height'; WordTable.cell (2, 2) .range.text: = '120cm'; WordTable.cell (3 1) .range.text: = 'Sit high'; WordTable.cell (3, 2) .Range.text: = '65cm'; WordDoc.saveas (filename); Application.MessageBox ('Output success! ',' Prompt box ', MB_OK;
Finally WordDoc.saved: = true; WordDoc.close; WordApp.quit; End;
END;