Runtime Error 5460

W

wjr

Is there a list of Runtime Errors? The following code works in Word
2003 but fails in Word 2007 with Runtime Error 5460.

ActiveDocument.SaveAs fileName:=fileName$ + ".", FileFormat:=wdFormatHTML

Thanks,
 
D

Doug Robbins - Word MVP

What is in the string fileName$? I would always use & to concatenate
strings and reserve + for arithmetic addition.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
W

wjr

fileName$ = ActiveDocument.FullName

I don't know about the '+' vs '&'. The person who wrote this code
hasn't been around in years. The code has been working all this time in
Word 2003, but doesn't seem to work in Word 2007. Will try the '&'
out to see if it works.
 
D

Doug Robbins - Word MVP

What is the present format of the document? The .FullName will include the
extension and you may have to strip it off.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

Graham Mayor

Change the line to
ActiveDocument.SaveAs FileName:=FileName$ + ".htm", FileFormat:=wdFormatHTML

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
W

wjr

So the file:
c:\Documents and Settings\wayne\Monarch\686.html
should be changed to:
c:\Documents and Settings\wayne\Monarch\686.html.htm
Doesn't seen correct. 686.html should be good. This code has been
working for years with Word 2003. Is there something about Word 2007
that requires .htm over .html?
 
W

wjr

The document is and html document.
c:\Documents and Settings\wayne\Monarch\686.html

Now this has been working for YEARS in Word 2003. Is there something
you know about Word 2007 that alters this behaviour?
 
G

Graham Mayor

Your original macro does not add an extension. It terminates with a full
stop (period). So if your document was already named "filename.html" it
would now be named "filename.html.".

As Doug posted eons ago, you need to remove the original filename extension
and apply the required extension.

In Word 2003, the macro ignores the unwanted full stop (period) and you get
the same extension that you had originally, so if that was doc it remains
doc, whereas Word 2007 does what you ask literally and baulks at the result.

In both versions you need to apply the required extension. I suggested htm,
but you can use html. This will double the extension (which works), but it
would be more elegant to remove the original extension eg

Dim oDoc As Document
Dim strDocname As String
Dim intPos As Integer
Set oDoc = ActiveDocument
strDocname = oDoc.FullName
intPos = InStrRev(strDocname, ".")
strDocname = Left(strDocname, intPos - 1)
strDocname = strDocname & ".html"
oDoc.SaveAs FileName:=strDocname, _
FileFormat:=wdFormatHTML


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
W

wjr

Thanks, this sounds correct. We will be using html as we are involved
with Solaris as well.
 
W

wjr

With the new information Graham Mayor, the line was changed to

ActiveDocument.SaveAs fileName:=fileName$, FileFormat:=wdFormatHTML

Is is properly saving the file with the .html extension.
Thank you all!
 

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