April 2006
Beginner
1114 pages
98h 16m
English
control.Pages
Returns a collection of Page controls contained in the MultiPage control. Use the Pages collection to add or delete pages. The following code searches the workbook’s folder for bitmap files and then creates a new page to display each file:
Private Sub UserForm_Initialize( )
' Requires reference to the Microsoft Scripting Runtime.
Dim fo As New filesystemobject, fld As Folder, _
f As File, pg As Page
' Get the workbook folder.
Set fld = fo.GetFolder(ThisWorkbook.Path)
' Delete all the pages from the multipage control.
MultiPage1.Pages.Clear
' For each file in the folder.
For Each f In fld.Files
' If the file is a bitmap.
If fo.GetExtensionName(f) = "bmp" Then
' Create a page for it.
Set pg = MultiPage1.Pages.Add(, f.name)
' Load the picture in the page.
pg.Picture = LoadPicture(f)
pg.PictureSizeMode = fmPictureSizeModeZoom
End If
Next
End SubRead now
Unlock full access