从Word中删除不需要的分隔符

本文关键字:分隔符 不需要 删除 Word | 更新日期: 2023-09-27 18:09:15

我正在尝试在MS Word中创建一个信封。下面的代码将创建一个信封,但我在该页的顶部得到"section break (Next Page)"。我想删除它

 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
  • 的"信封"功能
  • 手动调整纸张大小和页边距(在Word中,使用菜单/色带),并将您的地址和返回地址放在您想要的位置
  • 使用宏记录器记录VBA命令来完成此操作
  • 将VBA代码移植到c#