C# Word’e Çoklu Resim Aktarma Örneği

R

Rooster

only business
Super Moderator
Joined
Aug 10, 2019
Messages
3,215
Reaction score
4,728
Location
Milano
Bu örneğimizde C# programı ile Microsoft Word‘ e çoklu resim aktarmayı yapacağız. Örneğimize geçelim. Öncelikle C# Windows Form uygulamamızı açıyoruz ve formumuzu aşağıdaki şekilde oluşturuyoruz.



1587501722088.png

,
Formumuzu oluşturduktan sonra Solution Explorer penceresinden Reference üzerinde sağ tıklayarak Add Reference diyoruz.
add_reference
Daha sonra “Microsoft Word 15.0 Object Library” ekliyoruz.
Kodlarımıza geçiyoruz. Butona çift tıklayarak Click event’ ına ;
add_reference_com
Code:
private void button1_Click(object sender, EventArgs e)
        {
            // Word uygulamasını oluşturuyoruz.
            Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.Application();
            // Yeni doküman oluşturuyoruz.
            WordApp.Documents.Add();
            // word açılıyor.
            WordApp.Visible = true;
          
            Microsoft.Office.Interop.Word.Document doc = WordApp.ActiveDocument;
            // OpenFileDialog ile seçim yapılması sağlanıyor.
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Images (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF";
            ofd.Title = "Select Image To Insert....";
            ofd.Multiselect = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                foreach (string filename in ofd.FileNames)
                {
                    doc.InlineShapes.AddPicture(filename, Type.Missing, Type.Missing, Type.Missing);
                }
            }
 
        }
kodlarını yazarak programımızı tamamlıyoruz. Programı çalıştırdığımızda Dialog penceresinden bilgisayarımız üzerinde istediğimiz resimleri seçerek Word‘ e aktarılmasını sağlamış oluyoruz.
 
SPAM IS FORBIDDEN!
  • SPAMMERS ARE BANNED FROM THE FORUM AND CANNOT USE ANY OF THE CHEATS
  • For example: thanks, thx, very good, asdqwe, working, ty and so on!
  • For example: Writing the same message over and over. thanks, thx and so on!
  • Copying and copying someone else's message is prohibited.
  • It is forbidden to send messages to increase the number of comments on threads that you have no knowledge of.
  • Write your own opinion when commenting!
  • If you see spam message, please let us know with the REPORT button!

Tema düzenleyici

Top Bottom