Jeff9687
asked on
VBA, picture object
Hello-- I have the attached code that's working fine on my computer but for some reason is crashing on someone else's w/ a "Type Mismatch" error at the "Set PicTemp = Selection" line... why would this be?
Thanks.
Thanks.
Public Sub GenerateGIF(sheet1, range1, control1, DataRange)
Sheets(sheet1).Activate
Sheets(sheet1).Range(range1).Select
Selection.Copy
Const FName As String = [directory is here]\temp.gif"
Dim pic_rng As Range
Dim ShTemp As Worksheet
Dim ChTemp As Chart
Dim PicTemp As Picture
Application.ScreenUpdating = False
Set pic_rng = Worksheets(sheet1).Range(range1)
Set ShTemp = Worksheets.Add
Charts.Add
ActiveChart.Location Where:=xlLocationAsObject, Name:=ShTemp.Name
ActiveChart.ChartArea.Select
ActiveSheet.Shapes("Chart 1").ScaleWidth 8, msoFalse, _
msoScaleFromBottomRight
ActiveSheet.Shapes("Chart 1").ScaleHeight 2, msoFalse, _
msoScaleFromBottomRight
Set ChTemp = ActiveChart
pic_rng.CopyPicture Appearance:=xlScreen, Format:=xlPicture
ChTemp.Paste
Set PicTemp = Selection
try to ignore this crash and continue to see if the rest of works or not.
add this to yr code and see.
on error resume next
Brgds
Wellous
add this to yr code and see.
on error resume next
Brgds
Wellous
ASKER
The issue seems to be that I built the application in Excel 2003 that has Microsoft Excel 11.0 Object Library in VBA references, and it's crashing in Excel 2007 that's using Microsoft Excel 12.0 Object Library... that's literally the only difference... the Excel version and all the other add-in's and VBA references are the same. Any idea why the Picture object would be working with the 11.0 object library and not 12.0, or how to get this to work?
btw i'm well aware of On Error Resume Next and On Error GoTo... this isn't gonna be that easy... :(
btw i'm well aware of On Error Resume Next and On Error GoTo... this isn't gonna be that easy... :(
Oh yeah,
This is good that you discovered the issue already..
If your early binding by adding the reference then you will incur issues with different class interfaces between different versions.
You can late bind Excel by declaring the variable as an object and using createobject. You must however be aware that some functions may not be available in older versions of Excel..
<Code>
Dim objEX As Object
Set objEX = CreateObject("Excel.Applic ation")
</Code>
You will also not have the intellisense associated with the early binding method
This link may help you with your Early/Late knowledge.
http://www.dicks-clicks.com/excel/ol...#Early_Binding
GL,
Wellous
This is good that you discovered the issue already..
If your early binding by adding the reference then you will incur issues with different class interfaces between different versions.
You can late bind Excel by declaring the variable as an object and using createobject. You must however be aware that some functions may not be available in older versions of Excel..
<Code>
Dim objEX As Object
Set objEX = CreateObject("Excel.Applic
</Code>
You will also not have the intellisense associated with the early binding method
This link may help you with your Early/Late knowledge.
http://www.dicks-clicks.com/excel/ol...#Early_Binding
GL,
Wellous
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The late binding worked.
Glad to help,
Thanks for the grades
Thanks for the grades
Check the "Add-ins" on your computer and compare them to the ones on the computer that this program is crashing on.
Ss