Microsoft KB Archive/190191

From BetaArchive Wiki

Article ID: 190191

Article Last Modified on 6/17/2005



APPLIES TO

  • Microsoft Excel 98 for Macintosh



This article was previously published under Q190191


SUMMARY

In Microsoft Excel 98 Macintosh Edition, you can add an Image control to a user form. The following are two ways to specify which picture file is displayed in the Image control:

  • You can specify the picture at design time -or-


  • You can specify the picture at run time.

NOTE: The technique you use depends on whether you want to store the picture file with your project.

The advantage of using the run-time method is that the picture file is not stored with the project, which minimizes the size of the project. However, if you distribute the project to others, you must remember to include the picture file with the project file, and you must provide instructions for placing the picture file in the correct location.

This article provides a sample Visual Basic for Applications macro that uses the LoadPicture function to load a picture file into an Image control during run time.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Creating the User Form and the Macro Code

To create the user form and the macro code, follow these steps:

  1. Save and close any open workbooks, create a new workbook, and then start the Visual Basic Editor by pressing OPTION+F11.
  2. On the Insert menu, click UserForm.
  3. Add an Image control near the upper-center portion of the user form.
  4. To activate the Properties window, press F6. Set the values for the properties of the Image control as described by the following list:

          Property   Value
          ----------------
          Name       Image1
          AutoSize   True
          Height     100
          Width      100
                            
  5. Add a command button control to the user form.
  6. Double-click the command button to open the code window for it.
  7. Type the following code into the code window:

        Private Sub CommandButton1_Click()
    
           ' Loads a clipart image into the Image control.
           ' NOTE: Replace "Macintosh HD" with the name of your hard disk.
           Image1.Picture = LoadPicture("Macintosh HD:Microsoft Office 98:" & _
              "Clipart:Popular:Agree")
    
        End Sub
                            
  8. To run the user form, press F5.
  9. Click the command button.

An image is loaded into the image control.

REFERENCES

For more information about the Image control, click the Office Assistant in the Visual Basic Editor, type image control, click Search, and then click to view "Things you can do with an Image control".

For more information about the Image control, from the Visual Basic Editor, click the Office Assistant, type image control, click Search, and then click to view "Things you can do with a picture on an Image control."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:

176476 OFF: Office Assistant Not Answering Visual Basic Questions



Additional query words: XL98

Keywords: kbhowto kbprogramming kbdtacode KB190191