0% found this document useful (0 votes)
12 views

Coding VBA - 2

The document contains a VBA script that retrieves image file names from a specified folder and populates them into an Excel sheet. It also includes a subroutine to display images in specific shapes on the sheet based on cell values. Additionally, there is a subroutine for print preview functionality of the selected sheets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Coding VBA - 2

The document contains a VBA script that retrieves image file names from a specified folder and populates them into an Excel sheet. It also includes a subroutine to display images in specific shapes on the sheet based on cell values. Additionally, there is a subroutine for print preview functionality of the selected sheets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Dim folderPath As String

Dim files() As String


Dim i As Integer
folderPath = "E:\Saved Pictures"
Sheet2.Shapes.Range(Array(shapeName)).Fill.Visible = True
Sheet2.Shapes.Range(Array(shapeName)).Fill.UserPicture
CStr(Sheet2.Range("U" & i).Value)

folderPath = folderPath & "\"


files = Filter(Split(CreateObject("WScript.Shell").Exec("cmd /c dir """ &
folderPath & "."" /b").
StdOut.ReadAll, vbCrLf), ".")
For i = 6 To 100
If i - 4 <= UBound(files) Then
Cells(i, 9).Value = files(i - 4) '9 adalah kolom I
Else
Exit For
End If
Next i
Sub TampilkanFoto()
Dim i As Integer

For i = 13 To 13
Dim shapeName As String
shapeName = "foto" & i - 5

If Sheet2.Range("V" & i).Value <> "" Then


Sheet2.Shapes.Range(Array(shapeName)).Fill.Visible = True
Sheet2.Shapes.Range(Array(shapeName)).Fill.UserPicture
CStr(Sheet2.Range("V" & i).Value)
Else
End If
Next i
Sub PrintPreview()
ActiveWindow.SelectedSheets.PrintPreview
End Sub

You might also like