3
Answers

putting textbox on a picture

Photo of mackie duenas

mackie duenas

11y
648
1
how to  link the picture as a template? and how to edit it with a textbox? pls help using C# codes in visual studio big thanks to all of you

Answers (3)

0
Photo of mackie duenas
NA 28 7.7k 11y
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;//<- this is what I am talking about
namespace generateletter
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
//  create offer letter
                try
                {
//  Just to kill WINWORD.EXE if it is running
                    killprocess("winword");
//  copy letter format to temp.doc
                    File.Copy("C:\\OfferLetter.doc", "c:\\temp.doc", true);   
//  create missing object
                    object missing = Missing.Value;
//  create Word application object
                    Word.Application wordApp = new Word.ApplicationClass();
//  create Word document object
                    Word.Document aDoc = null;
//  create & define filename object with temp.doc
                    object filename = "c:\\temp.doc";
//  if temp.doc available
                    if (File.Exists((string)filename))  
                    {
                        object readOnly = false;
                        object isVisible = false;
//  make visible Word application
                        wordApp.Visible = false;
//  open Word document named temp.doc
                        aDoc = wordApp.Documents.Open(ref filename, ref missing, 
ref readOnly, ref missing,ref missing, ref missing, 
ref missing, ref missing, ref missing, ref missing, 
ref missing,ref isVisible, ref missing, ref missing, 
ref missing, ref missing);
                        aDoc.Activate();
//  Call FindAndReplace()function for each change
                        this.FindAndReplace(wordApp, "<Date>", dtpDate.Text);
                        this.FindAndReplace(wordApp, "<Name>", txName.Text.Trim());
                        this.FindAndReplace(wordApp, "<Subject>", 
txtSubject.Text.Trim());
//  save temp.doc after modified
                        aDoc.Save();
                    }
                    else
                        MessageBox.Show("File does not exist.", 
"No File", MessageBoxButtons.OK, 
MessageBoxIcon.Information);
                    killprocess("winword");
                }
                catch (Exception)
                {
                    MessageBox.Show("Error in process.", "Internal Error", 
MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
}

        private void FindAndReplace(Word.Application wordApp, 
        object findText, object replaceText)
{   
            object matchCase = true;
            object matchWholeWord = true;
            object matchWildCards = false;
            object matchSoundsLike = false;
            object matchAllWordForms = false;
            object forward = true;
            object format = false;
            object matchControl = false;
            object read_only = false;
            object visible = true;
            object replace = 2;
            object wrap = 1;
            wordApp.Selection.Find.Execute(ref findText, ref matchCase,
                ref matchWholeWord, ref matchWildCards, ref matchSoundsLike,
                ref matchAllWordForms, ref forward, ref wrap, ref format,
                ref replaceText, ref replace, ref matchControl);
}
        }
    }

0
Photo of mackie duenas
NA 28 7.7k 11y
i want to develop a codes that can write official letters. My requirements were letter template & content that can be changed any time and application will help to get only inputs like sent to name, organization name, date, etc. and after that when user presses finish button, the letter should be ready for print out along with predefined content & inputs... 
0
Photo of Amit Ziv
NA 40 5.9k 11y
can you explain your question? i couldnt understand what is the problem and what do you want the code to do