2010 docx kelimesinin içindeki metni değiştirmek için kodum var.C# word interop her şeyi bulup değiştirin
object fileName = Path.Combine(System.Windows.Forms.Application.StartupPath, "document.docx");
Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application { Visible = true };
Microsoft.Office.Interop.Word.Document aDoc = wordApp.Documents.Open(ref fileName, ReadOnly: false, Visible: true);
aDoc.Activate();
Microsoft.Office.Interop.Word.Find fnd = wordApp.ActiveWindow.Selection.Find;
fnd.ClearFormatting();
fnd.Replacement.ClearFormatting();
fnd.Forward = true;
fnd.Wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
fnd.Text = "{id}";
fnd.Replacement.Text = "123456";
fnd.Execute(Replace: WdReplace.wdReplaceAll);
Bu biçimlendirme olmadan çalışır. Ancak, {id} formatlandığında, metni değiştirmez.
Bu kod biçimlendirmeyi yok saymayı nasıl sağlayabilirim?
Wow! Şaşırtıcı, teşekkürler! – Lukas
Yardım etmek için mutluyum :) – joecop
Bu tutarsız. Bazen çalışır, bazen olmaz. –