×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

THUMBNAIL VIEW to EXCEL

THUMBNAIL VIEW to EXCEL

THUMBNAIL VIEW to EXCEL

(OP)
I am trying to see if it is possible to take the thumbnail view that you see when opening a file and placing it in another program as a picture.  Has anyone tried this and if so how do you do it?

Thanks

RE: THUMBNAIL VIEW to EXCEL

That file is a Bitmap image saved in the file code itself. If you can extract that being a code writer then maybe otherwise you won't be able too. You can do a Screen capture (alt-Print screen) and it will capture the active window. Use a Image software (Example: Paint shop pro) and crop it to fit and place that in Excel.

Regards,

Scott Baugh, CSWP pc2
www.scottjbaugh.com
"If it's not broke, Don't fix it!"
FAQ731-376: Eng-Tips.com Forum Policies

RE: THUMBNAIL VIEW to EXCEL

There is some sample code in the SW API Help to extract the bitmap directly from the SolidWorks file. The code works great if in a SolidWorks Macro. But if I use that same code in an Excel Macro, I get a "Catastrophic Failure" Run-time Error. So the work around I've been doing is to save a jpeg of the SW file each time, then display that jpeg in Excel.

Here is the code to extract the preview image. You'll need a form called "Userform1", an image box called "Image1", and a file at "C:\Part1.SLDPRT".

If you get this to work let me know,
Ken

CODE

Option Explicit

Sub GetSwPreviewImage(strSwPreviewFilenameAndPath As String, Optional strSwConfig As String)
    
    Dim swApp As SldWorks.SldWorks
    Dim swPreview As IPictureDisp
'    Dim swPreview As stdole.StdPicture  'Get Preview Bitmap Example (VB), See MSDN for details about the StdPicture object
    Dim vConfName As Variant
    Dim lngCount As Long
    Dim boolConfigNameExists As Boolean
    
'Need this for SW    Set swApp = Application.SldWorks
'Need this for Excel    Set swApp = GetObject(, "SldWorks.Application")
    
    vConfName = swApp.GetConfigurationNames(strSwPreviewFilenameAndPath)
    If IsEmpty(vConfName) Then
        vConfName = swApp.GetConfigurationNames(strSwPreviewFilenameAndPath)
    End If
    
    boolConfigNameExists = False
    For lngCount = 0 To UBound(vConfName)
        If vConfName(lngCount) = strSwConfig Then
            boolConfigNameExists = True
        End If
    Next lngCount
    
    If boolConfigNameExists Then
        'nothing
    Else
        boolConfigNameExists = False
        For lngCount = 0 To UBound(vConfName)
            If vConfName(lngCount) = "Default" Then
                boolConfigNameExists = True
            End If
        Next lngCount
        
        If boolConfigNameExists Then
            strSwConfig = "Default"
        Else
            strSwConfig = vConfName(1)
        End If
    End If

    Set swPreview = swApp.GetPreviewBitmap(strSwPreviewFilenameAndPath, strSwConfig)
'    Set UserForm1.Image1.Picture = swPreview
    
End Sub

Sub main()

    Load UserForm1
    
    Call GetSwPreviewImage("C:\Part1.SLDPRT", "Default")
    
    UserForm1.Show

End Sub


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources