Print using a userform


New Member
Hi all,

I have been searching for a code to print files from a company server (shared folder) but I can't get any working.

On the userform I would like to have two comboboxes and a listbox. The first combobox would be populated by subfolders within a folder named "Projects" (which is saved on the company server). The second combobox to select a subfolder within the folder selected in the first combobox. Once a folder is selected the listbox would then be populated with the files within the selected folder from the second combobox which are usually all pdf's.

Once all the pdf's are shown in the listbox I can then select all or select multiple files and click a print button.

Could anyone share a code they have came across for this or write a code for me that would work. I have tried myself but could not get anything working as I am new to vba.

Last edited:


New Member
I don't have any codes that work the way I want them to

Private Sub UserForm_Initialize()
Dim FD As FileDialog
Set FD = Application.FileDialog(msoFileDialogFolderPicker)

If FD.Show = -1 Then
Folder_path = FD.SelectedItems(1)
Filename = Dir(Folder_path & "\*.pdf", vbNormal) '.doc,.pdf etc

Do While Len(Filename) > 0
UserForm7.ListBox1.AddItem Filename
Filename = Dir()

End If

End Sub
This code populates the listbox on the userform with pdf's from a saved folder

I have a command button for printing. I would like to be able to select multiple pdf's from the listbox and click print

Some videos you may like

This Week's Hot Topics