Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Replace ImagePlaceHolder1 in Word 2007 with the image selected in Combo box in C#.net Windows Application

Replace ImagePlaceHolder1 in Word 2007 with the image selected in Combo box in C#.net Windows Application

Scheduled Pinned Locked Moved ASP.NET
csharphelptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raghvendrapanda
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • R raghvendrapanda

      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

      P Offline
      P Offline
      Prosanta Kundu online
      wrote on last edited by
      #2

      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 With

      Also this [link] might help you.

      R 1 Reply Last reply
      0
      • P Prosanta Kundu online

        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 With

        Also this [link] might help you.

        R Offline
        R Offline
        raghvendrapanda
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups