使用书签和Visual Studio C#替换word文档中的文本
问题描述:
您好,
我有一个代码可以使用书签功能和Visual Studio C#作为视频建议https://www.youtube.com/watch? v = X3mlQd3vMC8
但是代码在VB中,如何让它在C#中运行?
我喜欢从中获取名称actionpane在文本框中的第一个每日名称和最后一个每日名称和日期。
查看代码。
灵感的问候,
WIlco
我尝试了什么:
ThisDocument.CS
Hello,
I have a code to use the bookmark function and Visual Studio C# as the video suggest https://www.youtube.com/watch?v=X3mlQd3vMC8
But the code is in VB, how to get it work in C#?
I like to get the names from the actionpane in the text box first daily name and last daily name, and date.
See code.
Inspired greetings,
WIlco
What I have tried:
ThisDocument.CS
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Linq;
using Microsoft.Office.Tools.Word;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Office = Microsoft.Office.Core;
using Word = Microsoft.Office.Interop.Word;
namespace CuriosityReportNew
{
public partial class ThisDocument
{
private void ThisDocument_Startup(object sender, System.EventArgs e)
{
Me.BirthDateTimePicker1.Text = DateTimePicker ToString
Me.DailyFIrstNameInput = Add(new Daily_First_Name_Listbox)
Me.DailyLastNameInput = Add(new Daily_Last_Name_Listbox)
}
private void ThisDocument_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisDocument_Startup);
this.Shutdown += new System.EventHandler(ThisDocument_Shutdown);
}
#endregion
}
}
ActionPane.CS
ActionPane.CS
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Office = Microsoft.Office.Core;
namespace CuriosityReportNew
{
partial class ActionsPaneControl1 : UserControl
{
public ActionsPaneControl1()
{
InitializeComponent();
}
private void ActionsPaneControl1_Load(object sender, EventArgs e)
{
}
private void Daily_First_Name_SelectedIndexChanged(object sender, EventArgs e)
{
Globals.ThisDocument.DailyFirstNameBookmark.Text = Daily_First_Name_Listbox.SelectedItem
}
}
}
答
转换VB因为语法非常相似,所以C#反之亦然。您甚至可以使用在线工具。
Converting VB to C# and vice versa is very simple usually since the syntax is very similar. There are even online tools you can use.