Home > Back-end >  [for] BCB in form, change and insert the pictures and text box line??
[for] BCB in form, change and insert the pictures and text box line??

Time:10-26

See an example of the demon elder brother, try to form is formed in BCB, change the frame line and insert the pictures and words,
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:

reference 1st floor ccrun response:
OLE profession to also!!!!!!
To solve the problem of the insert picture:


Demon elder brother ~ super handsome!!
Originally I haven't Select
I have changed the ~ in the whole WORD can buy,
In addition to consult,
If I want to go back to the contents of the first grid, and then insert a new word with logo,
How to Select??

Thank you ~ ~

 

///just before
VSelect. OlePropertyGet (" ParagraphFormat "). OlePropertySet (" Alignment ", 1);//in a

//...

//the first grid
VCell=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:

Back to the first grid or corresponding Cell Range Select again, if you want to insert the picture or text to the back of the existing data and can simulate down buttons, but may not be accurate,

CodePudding user response:

Thank you ~ I will try!!!!!
  • Related