Replace ImagePlaceHolder1 in Word 2007 with the image selected in Combo box in C#.net Windows Application
-
Hi, I have created one template in MsWord 2007 and placed ImagePlaceHolder1 in it.I am able to find and replace the text but how to find ImagePlaceHolder1 in that Word Doc and replace with the one i select in the combo. At the end I want to save it in .pdf format as shown below. object format = Word.WdSaveFormat.wdFormatPDF; _wordapp.ActiveDocument.SaveAs(ref save, ref format, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing); Want to submit this project today. Any help is appreciated. Thanks, Harish
-
Hi, I have created one template in MsWord 2007 and placed ImagePlaceHolder1 in it.I am able to find and replace the text but how to find ImagePlaceHolder1 in that Word Doc and replace with the one i select in the combo. At the end I want to save it in .pdf format as shown below. object format = Word.WdSaveFormat.wdFormatPDF; _wordapp.ActiveDocument.SaveAs(ref save, ref format, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing); Want to submit this project today. Any help is appreciated. Thanks, Harish
See the example in VB Code, How to find a imageplaceholder in the document
Selection.GoTo What:=wdGoToGraphic, Which:=wdGoToFirst, Count:=1, Name:=""
Selection.Find.ClearFormatting
With Selection.Find
.Text = "ImagePlaceHolder1"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End WithAlso this [link] might help you.
-
See the example in VB Code, How to find a imageplaceholder in the document
Selection.GoTo What:=wdGoToGraphic, Which:=wdGoToFirst, Count:=1, Name:=""
Selection.Find.ClearFormatting
With Selection.Find
.Text = "ImagePlaceHolder1"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End WithAlso this [link] might help you.
Instead of place holder i placed 'Sign1' Text in Word 2007 with this i tried your code to replace it with image but iam getting System.Drawing.Bitmap in .pdf while saving instead i should .jpg image Below is my code object[] Parameters; Parameters = new object[15]; Parameters[0] = "Sign1"; Parameters[1] = _missing; Parameters[2] = _missing; ; Parameters[3] = _missing; ; Parameters[4] = _missing; ; Parameters[5] = _missing; Parameters[6] = _missing; Parameters[7] = _missing; Parameters[8] = _missing; Parameters[9] = img; Parameters[10] = _missing; Parameters[11] = _missing; Parameters[12] = _missing; Parameters[13] = _missing; Parameters[14] = _missing; myfind.GetType().InvokeMember("Execute", BindingFlags.InvokeMethod, null, myfind, Parameters); I am getting from img = GetSignPath();//method used to Clipboard.SetDataObject(img); i am getting img from below mentioned code inside GetSignPath(); MemoryStream ms = new MemoryStream((byte[])ds.Tables[0].Rows[0]["SignatureImage"]); System.Drawing.Image img = System.Drawing.Image.FromStream(ms); imgPath = "C:\\" + comboempname.Text + ".JPG".Trim(); img.Save(imgPath); //return imgPath; return img; Any Help is Appreciated Thanks, Harish