با سلام
پیغام خطای Interop type 'Microsoft.Office.Interop.Word.ApplicationClass' cannot be embedded
یعنی چی؟؟؟؟؟؟؟؟؟؟
البته dll مربوطه رو تو refrenceها add کردما!!!!
با تشکر
با سلام
پیغام خطای Interop type 'Microsoft.Office.Interop.Word.ApplicationClass' cannot be embedded
یعنی چی؟؟؟؟؟؟؟؟؟؟
البته dll مربوطه رو تو refrenceها add کردما!!!!
با تشکر
ممنون
copy local غیر فعاله
Embeded Introp Types خودش true هست
ببینید دی ال ال در پوشه دیباگ پروژه قرار دارد؟
این را تست کنید ببینید مشکل حل میشود
یکبار دی ال ال را به پوشه دیباگ کپی کنید سپس به رفرنس ها د ی ال ال را در پوشه دیباگ اضافه کنید
بازم حل نشد
شما Target Framework تون رو چند ست شده؟ 4 یا 3 یا 2 ..
کدتون رو هم بگذارید.
میشه راهنمایی کنین Target Framework از کجا ببینم؟!!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Collections;
using System.Threading;
using Microsoft.Office.Interop.Word;
namespace wrd
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public int GetNoOfPagesDOC(string FileName)
{
int num = 0;
object fileName = FileName;
object readOnly = false;
object isVisible = true;
object objDNS = Word.WdSaveOptions.wdDoNotSaveChanges;
try
{
Word.ApplicationClass WordApp = new Word.ApplicationClass();
// give any file name of your choice.
// the way to handle parameters you don't
care
about in .NET
object missing = System.
Reflection
.Missing.Value;
// Make word visible, so you can see what's happening
//WordApp.Visible = true;
// Open the document that was chosen by the dialog
Word.Document 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);
Word.WdStatistic stat = Word.WdStatistic.wdStatisticPages;
num = aDoc.ComputeStatistics(stat, ref missing);
WordApp.Quit(ref objDNS, ref missing, ref missing);
aDoc = null;
WordApp = null;
GC.Collect();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return num;
}
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
}
private void button2_Click(object sender, System.EventArgs e)
{
MessageBox.Show(GetNoOfPagesDOC(textBox1.Text).ToS tring());
}
}
}
راست کلیک روی پروژه و انتخاب Properties و Target Framework.
اینو تست کن:
Word.ApplicationClass WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
target روی 4
کدی که دادین
الان فقط واسه word پیغام not fount میده ،ایا به dll ربط داره یا کتابخونه ی دیگه ای میخاد؟؟
آخرین ویرایش به وسیله nooshin609 : چهارشنبه 22 خرداد 1392 در 13:27 عصر