Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub ShScreenShoot_Click()
- Dim Sht As Variant, Sh As Variant
- Dim sFolder As String
- Dim RnT As Range
- With Application.FileDialog(msoFileDialogFolderPicker)
- If .Show = -1 Then ' if OK
- sFolder = .SelectedItems(1)
- End If
- End With
- If sFolder = "" Then Exit Sub
- Sht = Array("OM D0", "OM CO1", "OM CO2", "OM CO3" _
- , "D0(PE)", "CO1", "CO2", "CO3", "D0", _
- "CO1-", "CO2-", "CO3-", "TL", "OM")
- For Each Sh In Sht
- Set RnT = getRange(Sh)
- BuatScreenShoot RnT, sFolder & "\Img" & Sh & ".jpg"
- Next
- End Sub
- Sub BuatScreenShoot(Rng As Range, Alamat As String)
- Dim i As Integer
- Dim intCount As Integer
- Dim objPic As Shape
- Dim objChart As Chart
- Call Rng.CopyPicture(xlScreen, xlPicture)
- intCount = Sheets("Temp").Shapes.Count
- For i = 1 To intCount
- Sheets("Temp").Shapes.Item(1).Delete
- Next i
- With Sheets("Temp")
- .Shapes.AddChart
- .Activate
- .Shapes.Item(1).Select
- Set objChart = ActiveChart
- .Shapes.Item(1).Line.Visible = msoFalse
- .Shapes.Item(1).Width = Rng.Width
- .Shapes.Item(1).Height = Rng.Height
- End With
- objChart.Paste
- Debug.Print Alamat
- objChart.Export (Alamat)
- End Sub
- Function getRange(Sh As Variant) As Range
- Dim brs As Long
- Dim Klm As Long
- Dim MaxKl As Long
- Dim Sht As Worksheet
- Set Sht = Sheets(Sh)
- brs = Sht.Range("B" & Sht.Rows.Count).End(xlUp).Row
- For i = 1 To brs
- Klm = Sht.Cells(i, Sht.Columns.Count).End(xlToLeft).Column
- If MaxKl < Klm Then
- MaxKl = Klm
- End If
- Next i
- Set getRange = Sht.Range(Sht.Cells(1, 1), Sht.Cells(brs, MaxKl))
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement