在没有标题的单词中插入新页面 [英] Insert a new page in word without header

查看:122
本文介绍了在没有标题的单词中插入新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在单词中插入新页面,即插入分节符.问题是我想将此页面更改为A3横向并删除所有标头,而我的代码当前不执行此操作.如何在下面修改我的代码以实现此目的?

I am trying to insert a new page in word i.e insert a section break. The problem is that i want to change this page to A3 landscape and remove all headers, which my code currently does not do. How to modify my code below to achieve this?

下面是我当前插入新页面的代码,但保留标题和a4纵向:

Below is my current code that insert new page, but keeps the header and a4 portrait:

If wordDrawingExist Then
    Selection.EndKey Unit:=wdStory
    Selection.InsertFile FileName:=wFile, link:=False

    Set wb = Documents.Open(wFile)
    Selection.WholeStory
    Selection.Copy
    Documents(docLogSkjema).Activate
    Selection.EndKey Unit:=wdLine
    Selection.InsertBreak Type:=wdPageBreak
    Selection.Paste

    wb.Close False
End If

wFile是wordfile的完整路径,基本上是freepdfsolutions.com的pdf转换为word的文件(尝试直接插入pdf,但是pdf的质量很差,以至于数字难以阅读)和wordDrawingExist boolean是说wordfile是否存在

wFile is fullpath to a wordfile, which is basically a pdf to word from freepdfsolutions.com (Tried inserting the pdf directly but then the quality of the pdf was so bad that numbers were hard to read) and wordDrawingExist is the boolean saying if the wordfile exist or not

推荐答案

好的,首先,您需要分节符,而不是简单的分页符:

OK, first of all, you will need a section break, not a simple page break:

Selection.InsertBreak Type:=wdSectionBreakNextPage

要更改为横向,请执行以下操作:

To change to landscape orientation:

Selection.PageSetup.Orientation = wdOrientLandscape

确保您位于要更改的部分.请注意,插入分节符后,光标将位于新节中.

Make sure you are in the section you want to change. Note that after inserting the section break, the cursor will be in the new section.

要将尺寸更改为A3,您需要手动设置尺寸:

To change the size to A3, you will need to set the size manually:

With Selection.PageSetup
 .PageWidth = CentimetersToPoints(42)
 .PageHeight = CentimetersToPoints(29.7)
End With

要删除标题,请执行以下操作:

To delete the header:

selection.Sections(1).Headers(wdHeaderFooterPrimary).Range.Delete

您的选择不包括多个部分,因此从它触及的一个部分中,您需要第一个(duh),因此需要Sections(1).

Your selection doesn't include multiple sections, so from the one section it touches, you need the first (duh) hence the Sections(1).

将它们放在一起:

Selection.InsertBreak Type:=wdSectionBreakNextPage
With Selection.PageSetup
 .Orientation = wdOrientLandscape
 .PageWidth = CentimetersToPoints(42)
 .PageHeight = CentimetersToPoints(29.7)
End With
Selection.Sections(1).Headers(wdHeaderFooterPrimary).Range.Delete

此代码将插入一个新的节+分页符,将此新节设置为横向A3,并从其中删除标题.

This code will insert a new section+page break, set this new section to landscape A3, and remove the headers from it.

注意:在删除之前,您可能需要取消标题的链接:

Note: You might need to unlink the headers before deleting it:

selection.Sections(1).Headers(wdHeaderFooterPrimary).LinkToPrevious=False

希望这会有所帮助.

这篇关于在没有标题的单词中插入新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆