在Word中适应Kindle K4 layout的宏
Sub WordToPdfForKindle()
'
' kindle 宏
'
'该宏主要功能为:删除页眉页脚,文档改为9CM*12CM(kindle4的大小),所有文字改为13号字体,文档边缘空白0.2厘米,另存为PDF文件至D盘
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader '删除页眉
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter ’删除页脚
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
With ActiveDocument.PageSetup '以下为调整文档格式
.TopMargin = CentimetersToPoints(0.2)
.BottomMargin = CentimetersToPoints(0.2)
.LeftMargin = CentimetersToPoints(0.2)
.RightMargin = CentimetersToPoints(0.2)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(0)
.FooterDistance = CentimetersToPoints(0)
.PageWidth = CentimetersToPoints(9) '这里改文档宽度,默认是9CM
.PageHeight = CentimetersToPoints(12) ’这里改文档高度,默认是12CM
End With
Selection.WholeStory
Selection.Font.Size = 13 '这里可以改字体大小,如果觉得我这个有点小,可以试试14或者15等等
Dim strNewName$ '获取当前文档名称
strNewName = ActiveDocument.Name
If (LCase$(Right$(strNewName, 4)) = ".doc") Then strNewName = Left$(strNewName, Len(strNewName) - 4)
If (LCase$(Right$(strNewName, 5)) = ".docx") Then strNewName = Left$(strNewName, Len(strNewName) - 5)
'下面第二行的那个"D:\" 可以改成自己想要存放的地址,例如可以改成 "e:\电子书\" 地址请保证最后用\结尾 两边加双引号
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
"D:\" & strNewName & ".pdf", ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=True, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
End Sub