From: geebee on

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 Where:=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.BackgroundChecking = 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.BackgroundChecking = 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

From: JLGWhiz on
I cannot duplicate the error. It runs OK in xl03.



"geebee" <geraldjr30(a)hotmail.com(noSPAMs)> wrote in message
news:8C3E053A-A950-4431-935F-7AB8081CA21A(a)microsoft.com...
>
> 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 Where:=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.BackgroundChecking = 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.BackgroundChecking = 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
>


From: geebee on
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" <geraldjr30(a)hotmail.com(noSPAMs)> wrote in message
> news:8C3E053A-A950-4431-935F-7AB8081CA21A(a)microsoft.com...
> >
> > 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 Where:=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.BackgroundChecking = 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.BackgroundChecking = 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
> >
>
>
> .
>