DDE errors in Excel

J

Jim

I have a VB application from which I am attempting to open
an Excel document via the ShellExecute function.

Until just a few minutes ago, the function was calling
Excel but was then generating a DDE error message and
failing to open the document. I went into Windows Explorer
and used Folder Options / File Types to change the command
used to open .XLS files, removing the "/e" at the end of
the command. Now the Excel document opens properly... but
*the error message is still appearing*. The message
appears in a window with a title of Microsoft Excel, and
the message says "A DDE error has occurred, and a
description of the error cannot be displayed because it is
too long. If the filename or path is too long, try
renaming the file or copying it to a different folder.".
The complete path to the Excel document being opened
is "C:\Jimstest.xls" so I know the length of the path
cannot be causing it.

I must figure out a way to allow the document to be opened
without generating an error message, and preferably
WITHOUT having to remove the "/e" from the end of the
Excel document Open command. Any advice that anyone might
have would be greatly appreciated.
 
D

Dave Peterson

I don't speak VB, but this worked ok for me from MSWord:

Option Explicit
Sub testme()

Dim myXL As Object

Set myXL = Nothing
On Error Resume Next
Set myXL = GetObject(, "Excel.Application")
If Err.Number = 429 Then
Set myXL = CreateObject("Excel.Application")
End If
On Error GoTo 0

myXL.Visible = True

myXL.Workbooks.Open Filename:="C:\jimstest.xls"

Set myXL = Nothing

End Sub
 

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