c# 检查word文档中是否存在页码、分栏、页眉、页脚 求救呀 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 WordApp.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader;http://topic.csdn.net/u/20100925/16/351ce800-dfdb-413d-b6ca-2870b86340d7.html 看看相关文档C#操作word/// <summary> /// 插入页脚 /// </summary> /// <param name="text">页脚文本</param> /// <param name="font">页脚字体</param> /// <param name="alignment">显示方式</param> private void InsertPageFooter(string text, System.Drawing.Font font, Alignment alignment) { try { wordapp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageFooter; wordapp.Selection.InsertAfter(text); GetWordFont(wordapp.Selection.Font, font); SetAlignment(wordapp.Selection.Range, alignment); } catch (Exception ex) { context.Response.Write(ex.Source + "->" + ex.Message); } } /// <summary> /// 插入页码 /// </summary> /// <param name="font">页码字体</param> /// <param name="alignment">显示方式</param> private void InsertPageFooterNumber(System.Drawing.Font font, Alignment alignment) { try { wordapp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageHeader; wordapp.Selection.WholeStory(); wordapp.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone; wordapp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument; wordapp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageFooter; wordapp.Selection.TypeText("第"); object page = Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage; wordapp.Selection.Fields.Add(wordapp.Selection.Range, ref page, ref Nothing, ref Nothing); wordapp.Selection.TypeText("页/共"); object pages = Microsoft.Office.Interop.Word.WdFieldType.wdFieldNumPages; wordapp.Selection.Fields.Add(wordapp.Selection.Range, ref pages, ref Nothing, ref Nothing); wordapp.Selection.TypeText("页"); GetWordFont(wordapp.Selection.Font, font); SetAlignment(wordapp.Selection.Range, alignment); wordapp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument; } catch (Exception ex) { context.Response.Write(string.Format("<script language='javascript' type='text/javascript'>alert('{0}->{1}');</script>", ex.Source, ex.Message)); } } 这些是插入页脚 页码的代码 3楼,我现在不是要怎样设置页眉这些,而用判断word 文档里面是否含有页眉,我现在做的是改卷功能。 WordApp.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader;WordApp.ActiveWindow.ActivePane.View.SeekView判断这玩意是不是空,是空就是没有 C#应用程序生成安装卸载包时问题 c#开发的winform 程序如何在不安装.NET Framework 的系统中运行 c#关于数据库SQL的 有关C#项目里运行C++写的代码 可扩展性的网站设计 多控件重垒 C#WINFORM 合计 再次发帖求助,生成伪随机数 C#有前途吗?在辽宁这里好像都是Java一手遮天了!省外的朋友给些建议? 请问谁能提供C#中控件命名的规则?谢谢! 寻求大神指导 如何判断两个控件是否有覆盖的情况?
http://topic.csdn.net/u/20100925/16/351ce800-dfdb-413d-b6ca-2870b86340d7.html
/// 插入页脚
/// </summary>
/// <param name="text">页脚文本</param>
/// <param name="font">页脚字体</param>
/// <param name="alignment">显示方式</param>
private void InsertPageFooter(string text, System.Drawing.Font font, Alignment alignment)
{
try
{
wordapp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageFooter;
wordapp.Selection.InsertAfter(text);
GetWordFont(wordapp.Selection.Font, font);
SetAlignment(wordapp.Selection.Range, alignment);
}
catch (Exception ex)
{
context.Response.Write(ex.Source + "->" + ex.Message);
}
} /// <summary>
/// 插入页码
/// </summary>
/// <param name="font">页码字体</param>
/// <param name="alignment">显示方式</param>
private void InsertPageFooterNumber(System.Drawing.Font font, Alignment alignment)
{
try
{
wordapp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageHeader;
wordapp.Selection.WholeStory();
wordapp.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
wordapp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;
wordapp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageFooter;
wordapp.Selection.TypeText("第");
object page = Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage;
wordapp.Selection.Fields.Add(wordapp.Selection.Range, ref page, ref Nothing, ref Nothing);
wordapp.Selection.TypeText("页/共");
object pages = Microsoft.Office.Interop.Word.WdFieldType.wdFieldNumPages;
wordapp.Selection.Fields.Add(wordapp.Selection.Range, ref pages, ref Nothing, ref Nothing);
wordapp.Selection.TypeText("页");
GetWordFont(wordapp.Selection.Font, font);
SetAlignment(wordapp.Selection.Range, alignment);
wordapp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;
}
catch (Exception ex)
{
context.Response.Write(string.Format("<script language='javascript' type='text/javascript'>alert('{0}->{1}');</script>", ex.Source, ex.Message));
}
}
这些是插入页脚 页码的代码