Results 1 to 17 of 17

Type Mismatch Runtime Error 13

Threaded View

  1. #13
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: Type Mismatch Runtime Error 13

    Hi Excelbench,

    I created a little File that maybe is an Alternative for your.
    I Assumed that everyone has access to the Excelfolder and that you only use images for the news

    So i added a folder Pictures where you can put all the Pictures that you wanna show and name them like you would name the Entry on your "Database"
    Then when the User opens the File he gets the Userform and it loads all the Image Names into a Listbox
    When the user Clicks an Entry the Script opens another (empty) userform and sets the Background image to the Selected File
    I also added a self resize in the userform with a max size of 800x600 (can be adjusted)
    Important is that the Pictures can only be in BMP GIF or JPG Format

    Check it out and let me know if it works for you.
    Just download the Zip File and unpack the folder and Excel in the same location.
    I already added some test pictures that i got from your file.

    I think it saves you a lot of work

    for everybody that just wants to look at the Code:

    This all goes in the Userform "Main_Form"
    you also need a blank userform called "ShowImg"

    Private Sub DD_Choice_Click()
    ShowImg.Picture = LoadPicture(Me.DD_Choice.Value) ' Set Background Image of ShowIMG userform to selected Image
    ShowImg.Caption = Me.DD_Choice.List(Me.DD_Choice.ListIndex, 0) ' Set title equal to entry in listbox
    
    'get Picture Height and Width in Pixels
    PicHeight = Round(ShowImg.Picture.Height / 26.458)
    PicWidth = Round(ShowImg.Picture.Width / 26.458)
    
    'if width or Height is not with bounds (800x600) for example set size to max of 800x600
    ' if width or Height is smaller than 800x600 use that resolution
    If PicWidth > 800 Then
        ShowImg.Width = 800
    Else
        ShowImg.Width = PicWidth
    End If
    
    If PicHeight > 600 Then
        ShowImg.Height = 600
    Else
        ShowImg.Height = PicHeight
    End If
    
    'open the Showimg Form
    ShowImg.Show
    
    End Sub
    
    Private Sub Image1_Click()
    Dim mypath As String
    mypath = ThisWorkbook.Path & "\Pictures\"
    Call refreshlist(mypath)
    End Sub
    Private Sub UserForm_Initialize()
    Dim mypath As String
    
    'Show Always Centered to application
    Me.Left = (Application.Width - Me.Width) / 2
    Me.Top = (Application.Height - Me.Height) / 2
    
    mypath = ThisWorkbook.Path & "\Pictures\"
    Call refreshlist(mypath)
    End Sub
    
    Function refreshlist(mylocation As String)
    Me.DD_Choice.Clear 'Clear the Result Box
    If mylocation = "" Then ' Exit if there is no path
        Exit Function
    End If
    file = Dir(mylocation & "*" & Me.tb_search & "*") ' get list of files and include what is in the search field
    Do Until file = "" ' Loop through the Files
    If InStr(1, file, ".gif") > 0 Or InStr(1, file, ".bmp") > 0 Or InStr(1, file, ".jpg") > 0 Then 'make sure filestypes can be handled by loadpicture
                Me.DD_Choice.AddItem Left(file, InStr(file, ".") - 1) 'cut off the extension and add the name to column 1 in the listbox
                Me.DD_Choice.List(Me.DD_Choice.ListCount - 1, 1) = mylocation & file 'write the Full path to the second column which is not shown to the user and set to bound Column
    End If
      file = Dir() ' next file
    Loop
    End Function
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Runtime error 13 - type mismatch
    By Polluz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2014, 11:30 PM
  2. RunTime Error 13: Type MIsmatch
    By tariq2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2013, 10:47 AM
  3. [SOLVED] runtime error 13 type mismatch
    By chappie in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-30-2012, 10:12 PM
  4. Runtime Error 13 Type Mismatch
    By vtsoldier2010 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-30-2012, 12:59 PM
  5. [SOLVED] Runtime Error '13': Type mismatch
    By Linking to specific cells in pivot table in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-18-2005, 03:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1