Word中PageSetup不能复制吗

6lilu9 2020-07-16 10:17:36
如题:想将Fsinfos[0].FullName 这个文件中的页面设置 赋值给 当前文档第二节,但

一、试了试下面代码,一点效果没有

Word.Document oDocument_Other = App.Documents.Open(Fsinfos[0].FullName);
Word.PageSetup ResultPageSetup = oDocument_Other.PageSetup;
oDocument.Sections[2].PageSetup = ResultPageSetup;


二、试了试下面代码,直接报错

oDocument.Sections[2].PageSetup =oDocument_Other.PageSetup.Clone()


三、下面代码可行,但太费劲了(因为属性实在太多),不知可有好办法?

oDocument.Sections[2].PageSetup.TopMargin =28.3f;
oDocument.Sections[2].PageSetup.BottomMargin =14.15f;
oDocument.Sections[2].PageSetup.RightMargin = oDocument_Other.PageSetup.RightMargin;
oDocument.Sections[2].PageSetup.LeftMargin = oDocument_Other.PageSetup.LeftMargin;

...全文
2246 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
6lilu9 2020-07-17
  • 打赏
  • 举报
回复
引用 4 楼 孤独de猫 的回复:
最近在研究 NOPI ,楼主可以去github 下载瞅瞅,感觉 还蛮好用的。
想过,没用,原因: 1、一直用office,已经熟悉基本操作(虽然时不时加载出问题); 而NOPI一点没接触过,还要从头学 就是没有 为了一个功能而学习一套插件 的动力 2、感觉NOPI还是不成熟,比如说打印功能就没有; 等成熟再考虑吧, 谢谢你的建议。
孤独de猫 2020-07-16
  • 打赏
  • 举报
回复
https://github.com/tonyqus/npoi.git
孤独de猫 2020-07-16
  • 打赏
  • 举报
回复
最近在研究 NOPI ,楼主可以去github 下载瞅瞅,感觉 还蛮好用的。
江湖评谈 2020-07-16
  • 打赏
  • 举报
回复
微软自带? 可能版本问题
threenewbee 2020-07-16
  • 打赏
  • 举报
回复
在word录制一个宏,再照抄下代码。
6lilu9 2020-07-16
  • 打赏
  • 举报
回复
引用 1 楼 tangyanzhi1111 的回复:
微软自带? 可能版本问题
对呀,就是想用C#操作Word

111,093

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧