Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi, I recently started getting a Runtime error 91 Object variable or with block variable not set error message when running my code. I made no changes to my code, so I figure an update was done to the software via our LAN server. Can someone please tell me how to remedy this? The code that runs is in block 2. However, the error message/debug is pointing to the following line in block 1: ActiveChart.ChartType = xlColumnClustered (preface code) Option Explicit 'XL2GIF_module -- GIF_Snapshot Dim container As Chart Dim containerbok As Workbook Dim Obnavn As String Dim Sourcebok As Workbook (1) Private Sub ImageContainer_init() Workbooks.Add (1) ActiveSheet.Name = "GIFcontainer" Charts.Add ActiveChart.ChartType = xlColumnClustered ActiveChart.SetSourceData Source:=Worksheets(1).Range("A1") ActiveChart.Location Whe=xlLocationAsObject, _ Name:="GIFcontainer" ActiveChart.ChartArea.ClearContents 'MsgBox ActiveChart.Name Set containerbok = ActiveWorkbook Set container = ActiveChart End Sub (2) Public Sub GIF_Snapshot_HASP() Dim varReturn As Variant Dim MyAddress As String Dim SaveName As Variant Dim MySuggest As String Dim Hi As Integer Dim Wi As Integer Dim Suffiks As Long ' disable background error checking Application.ErrorCheckingOptions.BackgroundCheckin g = False Set Sourcebok = ActiveWorkbook MySuggest = sShortname(ActiveSheet.Name) ImageContainer_init Sourcebok.Activate MyAddress = SelectArea_HASP If MyAddress < "A1" Then 'Dim ChDir 'ChDir "C:\DD\" SaveName = Application.GetSaveAsFilename( _ InitialFileName:=MySuggest _ & ".gif", fileFilter:="Gif Files (*.gif), *.gif") 'SaveName = "C:\DD\" & MySuggest & ".gif" 'Stop Range(MyAddress).Select Selection.CopyPicture Appearance:=xlScreen, _ Format:=xlBitmap If SaveName = False Then GoTo Avbryt End If If InStr(SaveName, ".") Then SaveName _ = Left(SaveName, InStr(SaveName, ".") - 1) Selection.CopyPicture Appearance:=xlScreen, _ Format:=xlBitmap Hi = Selection.Height + 4 'adjustment for gridlines Wi = Selection.Width + 6 'adjustment for gridlines containerbok.Activate ActiveSheet.ChartObjects(1).Activate MakeAndSizeChart ih:=Hi, iv:=Wi ActiveChart.Paste ' LCase (SaveName) & _ ' ".gif" ' bypass faulty file save name by hardcoding it 'ActiveChart.Export Filename:="test.gif", FilterName:="GIF" ActiveChart.Export Filename:=MySuggest & ".gif", FilterName:="GIF" ' enable background error checking Application.ErrorCheckingOptions.BackgroundCheckin g = True 'Dim oOutlookApp As Object, oOutlookMessage As Object 'Dim Body 'Set oOutlookApp = CreateObject("Outlook.Application") 'Set oOutlookMessage = oOutlookApp.CreateItem(0) 'ActiveChart.Paste 'Set Body = ActiveChart ActiveChart.Pictures(1).Delete Sourcebok.Activate Range("A1").Select End If Avbryt: On Error Resume Next Application.StatusBar = False containerbok.Saved = True containerbok.Close 'Stop End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I cannot duplicate the error. It runs OK in xl03.
"geebee" (noSPAMs) wrote in message ... Hi, I recently started getting a "Runtime error 91 Object variable or with block variable not set" error message when running my code. I made no changes to my code, so I figure an update was done to the software via our LAN server. Can someone please tell me how to remedy this? The code that runs is in block 2. However, the error message/debug is pointing to the following line in block 1: "ActiveChart.ChartType = xlColumnClustered" (preface code) Option Explicit 'XL2GIF_module -- GIF_Snapshot Dim container As Chart Dim containerbok As Workbook Dim Obnavn As String Dim Sourcebok As Workbook (1) Private Sub ImageContainer_init() Workbooks.Add (1) ActiveSheet.Name = "GIFcontainer" Charts.Add ActiveChart.ChartType = xlColumnClustered ActiveChart.SetSourceData Source:=Worksheets(1).Range("A1") ActiveChart.Location Whe=xlLocationAsObject, _ Name:="GIFcontainer" ActiveChart.ChartArea.ClearContents 'MsgBox ActiveChart.Name Set containerbok = ActiveWorkbook Set container = ActiveChart End Sub (2) Public Sub GIF_Snapshot_HASP() Dim varReturn As Variant Dim MyAddress As String Dim SaveName As Variant Dim MySuggest As String Dim Hi As Integer Dim Wi As Integer Dim Suffiks As Long ' disable background error checking Application.ErrorCheckingOptions.BackgroundCheckin g = False Set Sourcebok = ActiveWorkbook MySuggest = sShortname(ActiveSheet.Name) ImageContainer_init Sourcebok.Activate MyAddress = SelectArea_HASP If MyAddress < "A1" Then 'Dim ChDir 'ChDir "C:\DD\" SaveName = Application.GetSaveAsFilename( _ InitialFileName:=MySuggest _ & ".gif", fileFilter:="Gif Files (*.gif), *.gif") 'SaveName = "C:\DD\" & MySuggest & ".gif" 'Stop Range(MyAddress).Select Selection.CopyPicture Appearance:=xlScreen, _ Format:=xlBitmap If SaveName = False Then GoTo Avbryt End If If InStr(SaveName, ".") Then SaveName _ = Left(SaveName, InStr(SaveName, ".") - 1) Selection.CopyPicture Appearance:=xlScreen, _ Format:=xlBitmap Hi = Selection.Height + 4 'adjustment for gridlines Wi = Selection.Width + 6 'adjustment for gridlines containerbok.Activate ActiveSheet.ChartObjects(1).Activate MakeAndSizeChart ih:=Hi, iv:=Wi ActiveChart.Paste ' LCase (SaveName) & _ ' ".gif" ' bypass faulty file save name by hardcoding it 'ActiveChart.Export Filename:="test.gif", FilterName:="GIF" ActiveChart.Export Filename:=MySuggest & ".gif", FilterName:="GIF" ' enable background error checking Application.ErrorCheckingOptions.BackgroundCheckin g = True 'Dim oOutlookApp As Object, oOutlookMessage As Object 'Dim Body 'Set oOutlookApp = CreateObject("Outlook.Application") 'Set oOutlookMessage = oOutlookApp.CreateItem(0) 'ActiveChart.Paste 'Set Body = ActiveChart ActiveChart.Pictures(1).Delete Sourcebok.Activate Range("A1").Select End If Avbryt: On Error Resume Next Application.StatusBar = False containerbok.Saved = True containerbok.Close 'Stop End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am using Excel 2007. The strange thing is that it was working fine one
day. Then the next it just stopped working. I am not sure what was done behind the scenes to update the Excel SP or anything. Just would like to get this working again. Thanks in advance, geebee "JLGWhiz" wrote: I cannot duplicate the error. It runs OK in xl03. "geebee" (noSPAMs) wrote in message ... Hi, I recently started getting a "Runtime error 91 Object variable or with block variable not set" error message when running my code. I made no changes to my code, so I figure an update was done to the software via our LAN server. Can someone please tell me how to remedy this? The code that runs is in block 2. However, the error message/debug is pointing to the following line in block 1: "ActiveChart.ChartType = xlColumnClustered" (preface code) Option Explicit 'XL2GIF_module -- GIF_Snapshot Dim container As Chart Dim containerbok As Workbook Dim Obnavn As String Dim Sourcebok As Workbook (1) Private Sub ImageContainer_init() Workbooks.Add (1) ActiveSheet.Name = "GIFcontainer" Charts.Add ActiveChart.ChartType = xlColumnClustered ActiveChart.SetSourceData Source:=Worksheets(1).Range("A1") ActiveChart.Location Whe=xlLocationAsObject, _ Name:="GIFcontainer" ActiveChart.ChartArea.ClearContents 'MsgBox ActiveChart.Name Set containerbok = ActiveWorkbook Set container = ActiveChart End Sub (2) Public Sub GIF_Snapshot_HASP() Dim varReturn As Variant Dim MyAddress As String Dim SaveName As Variant Dim MySuggest As String Dim Hi As Integer Dim Wi As Integer Dim Suffiks As Long ' disable background error checking Application.ErrorCheckingOptions.BackgroundCheckin g = False Set Sourcebok = ActiveWorkbook MySuggest = sShortname(ActiveSheet.Name) ImageContainer_init Sourcebok.Activate MyAddress = SelectArea_HASP If MyAddress < "A1" Then 'Dim ChDir 'ChDir "C:\DD\" SaveName = Application.GetSaveAsFilename( _ InitialFileName:=MySuggest _ & ".gif", fileFilter:="Gif Files (*.gif), *.gif") 'SaveName = "C:\DD\" & MySuggest & ".gif" 'Stop Range(MyAddress).Select Selection.CopyPicture Appearance:=xlScreen, _ Format:=xlBitmap If SaveName = False Then GoTo Avbryt End If If InStr(SaveName, ".") Then SaveName _ = Left(SaveName, InStr(SaveName, ".") - 1) Selection.CopyPicture Appearance:=xlScreen, _ Format:=xlBitmap Hi = Selection.Height + 4 'adjustment for gridlines Wi = Selection.Width + 6 'adjustment for gridlines containerbok.Activate ActiveSheet.ChartObjects(1).Activate MakeAndSizeChart ih:=Hi, iv:=Wi ActiveChart.Paste ' LCase (SaveName) & _ ' ".gif" ' bypass faulty file save name by hardcoding it 'ActiveChart.Export Filename:="test.gif", FilterName:="GIF" ActiveChart.Export Filename:=MySuggest & ".gif", FilterName:="GIF" ' enable background error checking Application.ErrorCheckingOptions.BackgroundCheckin g = True 'Dim oOutlookApp As Object, oOutlookMessage As Object 'Dim Body 'Set oOutlookApp = CreateObject("Outlook.Application") 'Set oOutlookMessage = oOutlookApp.CreateItem(0) 'ActiveChart.Paste 'Set Body = ActiveChart ActiveChart.Pictures(1).Delete Sourcebok.Activate Range("A1").Select End If Avbryt: On Error Resume Next Application.StatusBar = False containerbok.Saved = True containerbok.Close 'Stop End Sub . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
runtime error '1004' application or object defined error | Excel Programming | |||
runtime error 13 - type mismatch error in Excel 97 on Citrix | Excel Programming | |||
runtime error '1004' application or object defined error. Please help | Excel Programming | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) | |||
Syntax Error Runtime Error '424' Object Required | Excel Programming |