- 帖子
- 31
- 主題
- 12
- 精華
- 0
- 積分
- 69
- 點名
- 0
- 作業系統
- WIN XP
- 軟體版本
- OFFICE 2003
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2011-8-19
- 最後登錄
- 2016-1-2
|
3#
發表於 2012-7-21 09:26
| 只看該作者
回復 2# kimbal
謝謝版大的指點 不過在經過測試之後
With PageSetup
If K <= 45 Then
.PrintArea = "A1:x45"
上式中的x 並非我要的型態(變數x)
與 x = i 的x 無法連結
可否請大大在幫我看一下^-^:D
還有一個小問題就是 Trim(Str(K)) 這串是什麼意思???:Q- Private Sub CommandButton1_Click()
- Dim Fs, t, Wb As Workbook, St As Worksheet
- Dim K%, x%, i%
- Fs = Application.GetOpenFilename("Excel,*.xls", , , , True) '
- If Not IsArray(Fs) Then Exit Sub
- For Each t In Fs
- If t <> ThisWorkbook.Name Then
- Set Wb = GetObject(t)
- For Each St In Wb.Worksheets
-
- With St.Cells
- K = .Range("B65536").End(xlUp).Row
- End With
-
- With St.Range("A9:O9")
- For i = .Cells.Count To 1 Step -1
- If .Cells(i).Borders.LineStyle = xlContinuous Then
- x = i
- Exit For
- End If
- Next
- End With
-
- With St.PageSetup
-
- If K <= 45 Then
- .PrintArea = "A1:x45"
- '.PrintArea = Range("A1:X45").Address
-
- ElseIf K <= 82 Then
- .PrintArea = "A1:x82"
- '.PrintArea = "A1:x82"
-
- ElseIf K <= 115 Then
- .PrintArea = "A1:x115"
- '.PrintArea = "A1:x115"
-
- ElseIf K <= 151 Then
- .PrintArea = "A1:x151"
- '.PrintArea = "A1:x151"
-
- Else
- .PrintArea = "A1:x" & Trim(Str(K)) '列印範圍"
- '.PrintArea = "A1:X" & Trim(Str(K))
- '.Zoom = 100 '縮放比例
- End If
- End With
-
- With St.Range("A12:x151").Borders
- 'With St.Range("A12:X151").Borders
- .LineStyle = xlContinuous '線種類 =實線
- .Weight = xlHairline '線粗細=極細
- .ColorIndex = 1 ' 線色 , 1=黑色
- End With
- St.PrintOut
-
- Next
- Wb.Close 0
- End If
- Next
- End Sub
複製代碼 |
|