Success in the form of the specified field into the text,
But have not been able to insert the picture, below is the program code, please welcome expert rescue?
PS. BCB can modify the WORK form the box line??
. Thank you ~ m (_ _) m
WideString strPicFile sTmp;
The Variant vWordApp vWordDocuments, vActiveDoc vShape, vSelect;
The Variant vTable, vCell;
VWordApp=CreateOleObject (" Word. Application ");
VWordApp. OlePropertySet (" Visible ", true);
VWordDocuments=vWordApp. OlePropertyGet (" Documents ");
VWordDocuments. OleFunction (" Add ");
VActiveDoc=vWordApp. OlePropertyGet (" ActiveDocument ");
VActiveDoc. OlePropertyGet (" PageSetup "). OlePropertySet (" TopMargin ", 35).
VActiveDoc. OlePropertyGet (" PageSetup "). OlePropertySet (BottomMargin, 20);
VActiveDoc. OlePropertyGet (" PageSetup "). OlePropertySet (RightMargin, 20);
VActiveDoc. OlePropertyGet (" PageSetup "). OlePropertySet (" LeftMargin ", 35).
VSelect=vWordApp. OlePropertyGet (" Selection ");
VTable=vWordApp. OlePropertyGet (" ActiveDocument ")
. OlePropertyGet (" Tables "). OleFunction (" Add ",
VSelect. OlePropertyGet (" Range "),
1,
3,//the number of columns
1,//DefaultTableBehavior:=wdWord9TableBehavior
0);//AutoFitBehavior:=wdAutoFitFixed
VCell=vTable. OleFunction (" Cell ", 1, 1);
VCell. OlePropertySet (" Range ", WideString (" test 1 \ r \ n "));
StrPicFile="C: \ \ A002166 JPG";
VWordApp. OlePropertyGet (" Selection "). OlePropertyGet (" InlineShapes "). OleFunction (" AddPicture strPicFile, false, true);
VCell=vTable. OleFunction (" Cell ", 1, 2);
VCell. OlePropertySet (" Range ", WideString (" 2 "));
StrPicFile="C: \ \ A002166-0322103253186 JPG".
VWordApp. OlePropertyGet (" Selection "). OlePropertyGet (" InlineShapes "). OleFunction (" AddPicture strPicFile, false, true);
CodePudding user response:
OLE profession to also!!!!!!To solve the problem of the insert picture:
//
the first gridVCell=vTable. OleFunction (" Cell ", 1, 1);
VCell. OlePropertyGet (" Range "). OleProcedure (" Select ");
//insert text
VWordApp. OlePropertyGet (" Selection "). OleProcedure (" TypeText ", WideString (" test 1 \ r \ n "));
//insert picture
StrPicFile="D: \ \ ccrun \ \ 1. JPG";
If (FileExists (strPicFile))
{
VWordApp. OlePropertyGet (" Selection "). OlePropertyGet (" InlineShapes ")
OleFunction (" AddPicture strPicFile, false, true);
}
//the second grid
VCell=vTable. OleFunction (" Cell ", 1, 2);
VCell. OlePropertyGet (" Range "). OleProcedure (" Select ");
//insert text
VWordApp. OlePropertyGet (" Selection "). OleProcedure (" TypeText ", WideString (" test 2 \ r \ n "));
//insert picture
StrPicFile="D: \ \ ccrun \ \ 2. JPG";
If (FileExists (strPicFile))
{
VWordApp. OlePropertyGet (" Selection "). OlePropertyGet (" InlineShapes ")
OleFunction (" AddPicture strPicFile, false, true);
}
CodePudding user response: