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

发布于 2024-12-05 15:59:40 字数 2496 浏览 1 评论 0原文

我正在尝试在 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);

I am trying to create an envelope in MS Word. The following code will create an envelope, but I get "section break (Next Page)" at the top of that page. I would like to remove that.

 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);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡莣 2024-12-12 15:59:40

在摆弄了 Word 的信封功能后,我注意到这不是一个编程问题(尽管你让它看起来像一个)。如果您手动将信封插入文档中,您还会得到一个分节符,它将信封部分与文档的其余部分分开,因为两者的纸张尺寸不同。我没有找到一种简单的方法来轻松消除分节符,同时仍保持信封尺寸完整,因此我的建议是正确执行此操作:

  • 不要使用 Word 的“信封”功能
  • 手动调整纸张尺寸和边距(在 Word 中,使用菜单/功能区),并将地址和返回地址放置在您希望
  • 使用宏记录器记录 VBA 命令的位置,以将
  • VBA 代码移植到 C#

After fiddeling around with the envelope feature of Word, I noticed that this is not a programming question (although you made it looking like one). If you insert an envelope manually into a document, you will get also a section break, which splits the envelope part from the rest of the document, since both have different paper sizes. I did not find an easy way to get rid of that section break easily while still keeping the envelope size intact, so here is my advice to get this right:

  • don't use the "envelope" feature of Word
  • adjust paper size and margins manually (in Word, using the menus/ribbons), and place your Address and return address at the positions where you want them to be
  • use the macro recorder to record the VBA commands to do this
  • port the VBA code to C#
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文