You just got that shiny new digital camera, and then you downloaded a bunch of digital pictures to your computer. Next you want to create a simple Hypertext Markup Language (HTML) file so that you can burn the picture and HTML files to a CD that you can send to all your friends and family. How do you do this without having to manually code the HTML file? The following instructions will show you how.
Creating an HTML File List with VB - Coding the Program (Page 3 of 5 )
Since the program will run by clicking the Run Catalog button, you will need to create a click event for this object. To do this, double click the Run Catalog button. The code window will open, and will create a sub routine called cmdCatalog_click().
The next few sections will describe the code logic.
Error Checking
To try and prevent the program from causing problems in case it crashed, some error checking should be added. With this error checking added, here is the sub routine so far:
Private Sub cmdCatalog_Click
() On Error GoTo Err_cmdCatalog_Click Exit_cmdCatalog_Click: Exit Sub Err_cmdCatalog_Click: MsgBox Err.Description Resume Exit_cmdCatalog_Click End Sub
Creating the Picture Directory List
To create the directory listing, we would use the shell command to run a DOS command. Because Windows 2000 does not have the dir.com file, you would get file not found errors, so I used a batch file called dir.bat. Here is the sub routine so far
Private Sub cmdCatalog_Click
() On Error GoTo Err_cmdCatalog_Click 'run directory listing 'put the path in the shell command where you put the dir.bat file Dim RetVal RetVal = Shell("d:picturesdir.bat", 1) ' Run dir.bat Exit_cmdCatalog_Click: Exit Sub Err_cmdCatalog_Click: MsgBox Err.Description Resume Exit_cmdCatalog_Click End Sub
You will need to create a batch file, and save it as dir.bat As the remarks note, put this file somewhere, and change the path in the shell command.