Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 190
Default runtime error 91


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default runtime error 91

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 190
Default runtime error 91

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error '1004' application or object defined error Janis Excel Programming 4 November 18th 09 03:01 PM
runtime error 13 - type mismatch error in Excel 97 on Citrix Kevin Maher Excel Programming 7 March 8th 08 11:48 AM
runtime error '1004' application or object defined error. Please help deej Excel Programming 0 August 1st 07 09:26 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 09:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"