Re: object variable or with block variable not set



Well I think I found the problem. I found a post on another forum that
mentions Word 12 references in the registry. I deleted the one he mentioned
and that took care of part of the problem but there are other places in code
now that create similar errors. I backed up the registry and did a search on
it and there are TONS of references to Office 12 tools (outlook, word,
excel, etc) which mystifies me. I bought this machine last year. It had a
trial of Office 2007 (versoin 12) on it. I took it off and installed 11.
THis sucks because I have a feelign that all these office 12 references are
really screwing things up. I'm a bit nervous about removing all those
registry entries. There are about 200 of them.

"Keith" <keith@xxxxxxxxxxxxxx> wrote in message
news:uK$lbxhCKHA.4376@xxxxxxxxxxxxxxxxxxxxxxx
The really crazy thing is that if you watch the windows processes when
this code runs, WINWORD.exe does show up in there when it wasn't there
before that code ran (all instances of word were closed prior to running
the code below).

"Keith" <keith@xxxxxxxxxxxxxx> wrote in message
news:%23cIwhqhCKHA.5092@xxxxxxxxxxxxxxxxxxxxxxx
Something new. I commented out the OpenWord code so it's running as
folllows:


Public Sub subOpenWord()

' On Error Resume Next
' Set objWord = GetObject(, "Word.Application")
' If Err.Number <> 0 Then
Set objWord = Nothing
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.WindowState = wdWindowStateMaximize
' End If

End Sub

Now, on the line "Set objWord = CreateObject("Word.Application")" I get
the follwoing error:

Automation Error
Library not Registered.

Okay, Word 11 is in the references and it's not MISSING. Any ideas on
this? What's more is what I mentioned in another part of this thread is
that my code compiles just fine (wiht all my enumerations and references
to Word). So what's the deal? Anyone familiar with this problem?

Keith


"Keith" <keith@xxxxxxxxxxxxxx> wrote in message
news:ezDB$1gCKHA.4316@xxxxxxxxxxxxxxxxxxxxxxx
I'm running XP SP3 and Office 2003 SP3. I have 2GB RAM and tons of drive
space.

Same app, same code, etc. on my machine as on my clients' machines.

Here's an excerpt of my code. When the line "Set docWord =
objWord.Documents.Add(Template:=sWordFormsPath & "evidence.dot")" runs
as in the code below:

Option Compare Database
Option Explicit

'Global mywordform As Object
Global objWord As Word.Application
Global docWord As Word.Document
Global rngWord As Word.Range

Public Sub blahblah()
...
...

Call subOpenWord

Set docWord = objWord.Documents.Add(Template:=sWordFormsPath &
"evidence.dot")
...
...
...
End Sub

Public Sub subOpenWord()

On Error Resume Next
Set objWord = GetObject(, "Word.Application")
If Err.Number > 0 Then
Set objWord = CreateObject("word.application")
objWord.Visible = True
objWord.WindowState = wdWindowStateMaximize
End If

End Sub

Word is running in the background before this point.

I get the error "object variable or with block variable not set".

I tried some of the solutions here:
http://support.microsoft.com/kb/319832 but this seems like a total waste
of time since it's all working fine on several machines at 2 separate
client offices. Something's amiss on my machine or my Office setup or
????

Thanks,

Keith







.



Relevant Pages

  • Re: object variable or with block variable not set
    ... And since I have VS2008 installed which I think installs some things for ... mentions Word 12 references in the registry. ... Public Sub subOpenWord() ... ' Set objWord = GetObject ...
    (microsoft.public.access.formscoding)
  • Re: object variable or with block variable not set
    ... the problem was that there were registry entries for Word ... 12 due to the demo installation and Access was confused. ... Public Sub subOpenWord() ... Set objWord = CreateObject ...
    (microsoft.public.access.formscoding)
  • Re: HowTo: Unregister a DLL/Control when the File no longer Exists
    ... Tony Proctor wrote: ... recorded in the registry. ... However, matching them up without the original DLL ... The main project references one of the DLLs, ...
    (microsoft.public.vb.general.discussion)
  • Re: VBA Problems ... (since windows update?)
    ... "vanderghast" wrote: ... you MAY have a conflict of installation in the registry (but not ... Note that I am quite surprised that you have ONLY two references. ... Set objWord = CreateObject ...
    (microsoft.public.access.modulesdaovba)
  • Re: HowTo: Unregister a DLL/Control when the File no longer Exists
    ... projects, in the correct order, and deals with this exact situation Karl ... "registry bloat" by not cleaning the registry properly over a period ... The main project references one of the DLLs, ... another DLL. ...
    (microsoft.public.vb.general.discussion)