Error 462 occurred - Selection.HomeKey Unit := wdStory in Word 2003

A

Anony

Currently, I have a word 2000 report template that runs on Word 2000.
Once the report is generated, it automatically saves the report to C
drive. We're in the process of upgrading to Microsoft Office 2003 and
I've found out that when I run the report the first time where there
is no report on the C drive, I get an error "Error 462 occurred in the
class <classname where the error occurs> from source <procedure
name>: The remote server machine does not exist or is unavailable.

I don't get this error when I run the same report the second time
since it already exists on the C drive. The previous VB references to
run the report was Microsoft Office Object version 9.0 and Microsoft
Word Object version 9.0. After installing Office 2003, I've updated
the references to Office Object 11.0 and Word Object 11.0

Please advise. Thanks.
 
C

Cindy M -WordMVP-

Hi Anony,
Currently, I have a word 2000 report template that runs on Word 2000.
Once the report is generated, it automatically saves the report to C
drive. We're in the process of upgrading to Microsoft Office 2003 and
I've found out that when I run the report the first time where there
is no report on the C drive, I get an error "Error 462 occurred in the
class <classname where the error occurs> from source <procedure
name>: The remote server machine does not exist or is unavailable.
This just isn't enough information. I'd disable the error handling and
let the code run to see on exactly which line of code it hangs up. Then
copy the code in its context (so that we can see how it all fits
together) into your reply.
I don't get this error when I run the same report the second time
since it already exists on the C drive. The previous VB references to
run the report was Microsoft Office Object version 9.0 and Microsoft
Word Object version 9.0. After installing Office 2003, I've updated
the references to Office Object 11.0 and Word Object 11.0

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
A

Anony

Basically, the code fails at several places. One of them is
Selection.HomeKey Unit:= wdStory,
w.Selection.Paragraph.FirstLineIndent = InchesToPoints(-0.2) and
w.Selection.Paragraph.LeftIndent = InchesToPoints(-0.2)

Once I commented out these three lines of code in the module, the
report ran without any problem.

Please advise. Thanks.
 
C

Cindy M -WordMVP-

Hi Anony,
Basically, the code fails at several places. One of them is
Selection.HomeKey Unit:= wdStory,
w.Selection.Paragraph.FirstLineIndent = InchesToPoints(-0.2) and
w.Selection.Paragraph.LeftIndent = InchesToPoints(-0.2)

Once I commented out these three lines of code in the module, the
report ran without any problem.
Yes, this makes sense :) It's because you're not specifying
w.Selection.Homekey (no w)
w.InchesToPoints

However, it would be much better to work with Word's object model, rather than the
SELECTION object.
wdDoc.Paragraphs(1).FirstLineIndent = w.InchesToPoints(-0.2)

for example.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the
newsgroup and not by e-mail :)
 
A

Anony

BTW, can you please be more specific about the below:
However, it would be much better to work with Word's object model, rather than the
SELECTION object.
wdDoc.Paragraphs(1).FirstLineIndent = w.InchesToPoints(-0.2)

for example.

w is declared as an object. Are u saying instead of using
w.Selection.ParagraphFormat.FirstLineIndent = w.InchesToPoints(-0.2),
use
w.Paragraphs(1).FirstLineIndent = w.InchesToPoints(-0.2)

Please advise. Thanks.
 
C

Cindy M -WordMVP-

Hi Anony,
BTW, can you please be more specific about the below:


w is declared as an object. Are u saying instead of using
w.Selection.ParagraphFormat.FirstLineIndent = w.InchesToPoints(-0.2),
use
w.Paragraphs(1).FirstLineIndent = w.InchesToPoints(-0.2)
Assuming you wanted to specifically address the first paragraph in the document, yes.
(I see my head wasn't quite "with it" when I wrote that yesterday, as w represents the
application?) You'd need to address the document on the left-hand side of the equation,
the application on the right-hand side. Assuming this was a document you opened:

Dim wDoc as Word.Document
Set wDoc = w.Documents.Open("Doc name")
wDoc.Paragraphs(1).FirstLineIndent = w.InchesToPoints(-0.2)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the
newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top