title: Excel VBA - Insert image (using dialog box) into a certain cell
body: <p>So I've extensively searched through here and the various websites on the interwebs, but I'm having difficulty finding an answer. I'm also not the most VBA-savvy user.</p>
  
  <p>Basically, what I need:
  On a button click, the "Insert Image" dialog box pops up, the user selects a single image file, and the image should be inserted into cell B2. Ideally I would like to size this image so that it isn't any longer than X, and no taller than Y. </p>
  
  <p>This is my code so far (which gives me a 'Run-time error 424' and points to the TextBox1.Value line). Any suggestions/improvements are always greatly appreciated!</p>
  
  <pre><code>Sub ChangeImage()
  
  With Application.FileDialog(msoFileDialogFilePicker)
  .AllowMultiSelect = False
  .ButtonName = "Submit"
  .Title = "Select an image file"
  .Filters.Clear
  .Filters.Add "JPG", "*.JPG"
  .Filters.Add "JPEG File Interchange Format", "*.JPEG"
  .Filters.Add "Graphics Interchange Format", "*.GIF"
  .Filters.Add "Portable Network Graphics", "*.PNG"
  .Filters.Add "Tag Image File Format", "*.TIFF"
  .Filters.Add "All Pictures", "*.*"
  
  If .Show = -1 Then
      TextBox1.Value = .SelectedItems(1)
      Image1.PictureSizeMode = fmPictureSizeModeZoom
      Image1.Picture = LoadPicture(.SelectedItems(1))
  
  Else
      MsgBox ("Cancelled.")
  End If
  End With
  End Sub
  </code></pre>
  
  <p>Thanks!</p>
  
  <p>-A</p>