gpt4 book ai didi

c# - 从 Word 中删除不需要的分节符?

转载 作者:行者123 更新时间:2023-11-30 18:03:07 24 4
gpt4 key购买 nike

我正在尝试在 MS Word 中创建一个信封。下面的代码将创建一个信封,但我在该页的顶部得到了“分节符(下一页)”。我想删除它。

 oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
oDoc.Activate();
object ExtractAddress = false;
object Address = "Address" ;
object AutoText = "AutoText" ;
object OmitReturnAddress = false;
object ReturnAddress = "ReturnAddress" ;
object ReturnAutoText = "ReturnAutoText";
object PrintBarCode = false;
object PrintFIMA = false;
object Size = "E65";
object Height = 110;
object Width = 220;
object FeedSource = true;
object AddressFromLeft = 2;
object AddressFromTop = 2;
object ReturnAddressFromLeft = 2;
object ReturnAddressFromTop = 2;
object DefaultFaceUp = true;
object DefaultOrientation = Microsoft.Office.Interop.Word.WdEnvelopeOrientation.wdCenterPortrait;
object PrintEPostage = false;
object Vertical = false;
object RecipientNamefromLeft = Missing.Value;
object RecipientNamefromTop = Missing.Value;
object RecipientPostalfromLeft = Missing.Value;
object RecipientPostalfromTop = Missing.Value;
object SenderNamefromLeft = Missing.Value;
object SenderNamefromTop = Missing.Value;
object SenderPostalfromLeft = Missing.Value;
object SenderPostalfromTop = Missing.Value;
oDoc.Envelope.Insert(ref ExtractAddress, ref Address, ref AutoText,
ref OmitReturnAddress, ref ReturnAddress, ref ReturnAutoText,
ref PrintBarCode, ref PrintFIMA, ref Size, ref Height,
ref Width, ref FeedSource, ref AddressFromLeft, ref AddressFromTop,
ref ReturnAddressFromLeft, ref ReturnAddressFromTop, ref DefaultFaceUp,
ref DefaultOrientation, ref PrintEPostage, ref Vertical,
ref RecipientNamefromLeft, ref RecipientNamefromTop,
ref RecipientPostalfromLeft, ref RecipientPostalfromTop,
ref SenderNamefromLeft, ref SenderNamefromTop, ref SenderPostalfromLeft,
ref SenderPostalfromTop);

最佳答案

在摆弄了 Word 的信封功能之后,我注意到这不是一个编程问题(尽管你让它看起来像一个)。如果您手动将信封插入文档,您还会得到一个分节符,它将信封部分与文档的其余部分分开,因为两者的纸张尺寸不同。我没有找到一种简单的方法来轻松摆脱那个分节符,同时仍然保持信封大小不变,所以这里是我的建议来做到这一点:

  • 不要使用 Word 的“信封”功能
  • 手动调整纸张大小和边距(在 Word 中,使用菜单/功能区),并将您的地址和寄信人地址放在您希望的位置
  • 使用宏录制器录制 VBA 命令来执行此操作
  • 将 VBA 代码移植到 C#

关于c# - 从 Word 中删除不需要的分节符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7513229/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com