Created
December 20, 2013 11:12
-
-
Save ficapy/8053411 to your computer and use it in GitHub Desktop.
建筑资料栋号递增批量打印PDF输出
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
'建筑资料栋号递增批量打印PDF输出 | |
Sub replace() | |
Const F1 As String = "工程名称" '要修改单元格左边相邻单元格包含的内容 | |
Dim k As Integer | |
Dim sh As Worksheet | |
Dim myStr As String | |
Dim myStr2 As String | |
Dim myStr3 As String | |
Dim c As Range | |
For k = 1 To 3 '需要打印的栋号,默认跳过包含4的栋号 | |
myStr = k | |
If InStr(myStr, "4") = 0 Then | |
For Each sh In Worksheets | |
Set c = sh.UsedRange.Find(F1) | |
If Not c Is Nothing Then | |
myStr = sh.Cells(c.Row, c.End(xlToRight).Column) | |
myStr2 = Left(myStr, InStr(myStr, "(")) | |
myStr3 = myStr2 & k & "栋)" | |
sh.Cells(c.Row, c.End(xlToRight).Column) = myStr3 | |
Set c = Nothing | |
End If | |
Next sh | |
ThisWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ | |
ThisWorkbook.Path & "\" & ThisWorkbook.Name & k & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:= _ | |
True, IgnorePrintAreas:=False, OpenAfterPublish:=False | |
End If | |
Next k | |
End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment