944,126 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Aug 1st, 2006
0

runtime error 91 object variable or With block variable not set

Expand Post »
i wrote and compiled an vb 6 program on a windows xp sp2 box
i am trying to run the program via a batch file from an nt box
i get this error:
runtime error 91:
object variable or With block variable not set
the program runs under the scheduler on xp, and in debug in vb ide
thanks in advance for the help
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ronb is offline Offline
1 posts
since Aug 2006
Aug 1st, 2006
1

Re: runtime error 91 object variable or With block variable not set

It's possible that you are trying to create an instance of a class (an object) from a class that is present on the machines you tested it on, but not on the machine it's been deployed to..... for example, I happen to know that I can make a VB program utilize a class for Nero Burning Rom.... I can make a nero object, and use it's methods and properties...... but that will only work on machines that have the Nero libraries installed. If it's not installed, when you try to make the object (either through early or late bindings with new or createobject), the variable that SHOULD refer to the object is still set to Nothing, because the library failed to create an instance of the requested class.....

Basically, you are trying to make an object from a class that doesn't exist on the NT box.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Mar 24th, 2007
0

Re: runtime error 91 object variable or With block variable not set

when i want to setup certain program this messege appear
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ibrahim refaat is offline Offline
1 posts
since Mar 2007
Mar 24th, 2007
0

Re: runtime error 91 object variable or With block variable not set

in vb ide build an exe file
get a dependency walker and check which dependencies are needed for your exe file
create those dependencies on youre target machine
OR
get a setup (e.g. setupfactory) tool that builds a setup which does this for you
it can make a cabin file on development machine
that you can deploy on your target machine
Last edited by PVBert; Mar 24th, 2007 at 1:18 pm.
Reputation Points: 10
Solved Threads: 5
Junior Poster in Training
PVBert is offline Offline
60 posts
since Mar 2007
Jul 1st, 2008
0

Re: runtime error 91 object variable or With block variable not set

According to the MSDN library...
Error 91: Object variable or With block variable not set
---
There are two steps to creating an object variable. First you must declare
the object variable. Then you must assign a valid reference to the object
variable using the Set statement. Similarly, a With...End With block must be
initialized by executing the With statement entry point. This error has the
following causes and solutions:

You attempted to use an object variable that isn't yet referencing a valid
object.
Specify or respecify a reference for the object variable. For example, if
the Set statement is omitted in the following code, an error would be
generated on the reference to MyObject:

Dim MyObject As Object ' Create object variable.
Set MyObject = Sheets(1) ' Create valid object reference.
MyCount = MyObject.Count ' Assign Count value to MyCount.

You attempted to use an object variable that has been set to Nothing.
Set MyObject = Nothing ' Release the object.
MyCount = MyObject.Count ' Make a reference to a released object.

Respecify a reference for the object variable. For example, use a new Set
statement to set a new reference to the object.

The object is a valid object, but it wasn't set because the object library
in which it is described hasn't been selected in the References dialog box.
Select the object library in the Add References dialog box.

The target of a GoTo statement is inside a With block.
Don't jump into a With block. Make sure the block is initialized by
executing the With statement entry point.










Click to Expand / Collapse  Quote originally posted by ronb ...
i wrote and compiled an vb 6 program on a windows xp sp2 box
i am trying to run the program via a batch file from an nt box
i get this error:
runtime error 91:
object variable or With block variable not set
the program runs under the scheduler on xp, and in debug in vb ide
thanks in advance for the help
Reputation Points: 10
Solved Threads: 0
Newbie Poster
akodalikar is offline Offline
1 posts
since Jun 2008
Jul 22nd, 2009
0

Re: runtime error 91 object variable or With block variable not set

Private Sub Command1_Click()
Dim PDDoc As Object
Dim AVDoc As Object
Dim AcroExchApp As Object
Dim PDSaveFull As Object
AcroExchApp.GetActiveDoc
Set AcroExchApp = CreateObject("AcroExch.App")
AcroExchApp.GetActiveDoc
AVDoc.GetPDDoc
PDDoc.Save

Set PDDoc = AVDoc.GetPDDoc

If PDDoc.Save(PDSaveFull, "c:\test.pdf") = False Then
MsgBox "Unable to save image"
Else: MsgBox "The file is saved"
End If


End Sub

getting an error 91 whats wrong plzz help
Reputation Points: 10
Solved Threads: 0
Newbie Poster
avisek_cts is offline Offline
11 posts
since Jun 2009
Jul 22nd, 2009
0

Re: runtime error 91 object variable or With block variable not set

abisek_cts,

In the future please create your own thread and if you need to, copy the older threads url that you want to reference into your post.

Also please use code tags when submitting code. [ code ]your code goes here[ /code ] (without spaces as shown)

Now, I think you need to switch these two lines...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. AcroExchApp.GetActiveDoc
  2. Set AcroExchApp = CreateObject("AcroExch.App")
to
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Set AcroExchApp = CreateObject("AcroExch.App")
  2. AcroExchApp.GetActiveDoc
because you have not create the object yet and are trying to give it a command.


Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Jul 23rd, 2009
0

Re: runtime error 91 object variable or With block variable not set

will remeber it
can u send me the code what to write please...
the full code
Reputation Points: 10
Solved Threads: 0
Newbie Poster
avisek_cts is offline Offline
11 posts
since Jun 2009
Jul 23rd, 2009
0

Re: runtime error 91 object variable or With block variable not set

You posted the code...
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Jul 24th, 2009
0

Re: runtime error 91 object variable or With block variable not set

I don't think that you have to use the Set keyword because it is understood automatically by the compiler in assigning values to a variable. I also get the same problem but I think the error comes from the referencing of the assigned variable.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
markperfinan is offline Offline
6 posts
since Jul 2009
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB6 MSChart pie chart help
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Voice Command Application





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC