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
Thanks






RE: THUMBNAIL VIEW to EXCEL
Regards,
Scott Baugh, CSWP![[pc2] pc2](https://www.tipmaster.com/images/pc2.gif)
www.scottjbaugh.com
"If it's not broke, Don't fix it!"
FAQ731-376: Eng-Tips.com Forum Policies
RE: THUMBNAIL VIEW to 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
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