• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6407
  • Last Modified:

Excel (DDE) problem

Hi,
I have an application that uses Excel.
I open an excel worksheet in a picturebox to work with. (To avoid the excel toolbars and other options I disable those options in VB).
The problem is, that when I open another excel sheet (not linked to my application, e.g. Test.xls) the sheet will open in my application too (in my picturebox without the toolbars etc...).
I've noticed that when the DDE option in the File Type of excel workbook is checked off, this doesn't
occur. (in browser, tools, folder options, file type, excel worksheet ,edit the "open" possibility).

Is there a way to disable this DDE option in VB?

Note: When I open excel first and then I load a .xls file, it doesn't occur. It's only when I double click on a .xls file that it will open in my application (when it's running of course)

Hope somebody can help.
Catouch
0
Catouch
Asked:
Catouch
1 Solution
 
TimCotteeCommented:
Catouch, you could do this by editing the registry within your VB application. The check box that you set as described actually influences the registry. The following process using a registry class or api calls should achieve your desired aim:

Open the key \HKEY_CLASSES_ROOT\Excel.Sheet\CurVer\(Default) this will give you the current version of excel that is installed on the system, for example Excel.Sheet.8

Then open the key \HKEY_CLASSES_ROOT\<Value Returned Form Previous Call>\shell\Open\ddeexec\(Default) and set the value to "". This will stop the dde command being sent to Excel, you can then reset it to [open("%1")] later to re-enable the dde command.

Obviously as this is a registry hack it should be done carefully and you should test it thoroughly on a backed up machine before putting it out anywhere else.
0
 
CJ_SCommented:
DDE -> Dynamic Data Exchange
It is used to operate another program that is alrewady open. You can retrieve variable etc, as long as they have been set by the programmer. What do you mean by disabling DDE for VB? As long as the LinkMode is set to "none" DDE cannot be used with your application.

regards,
CJ
0
 
CJ_SCommented:
I probably just misunderstand the question though..
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
CatouchAuthor Commented:
It is the good solution TimCottee thanks.
Only one strange thing is going on.
The excel opens up when I double click on the Test.xls, but the Worksheet does not open.
I have an empty Excel.
When I then goto file open, i have my sheet.
Is this some other registry setting?
I'm granting you the points anyway, cause you found what I asked for, but do you know how I can fix this?
0
 
CatouchAuthor Commented:
ok, got it. it's the %1 param that has to be added.
Thanks TimCottee
0
 
Alon_hCommented:
try this ...

put excel file in "c:\excel\book1.xls"

and then run this code from word...


   Sub Main
      Q$ = Chr$(34)
      ' Initiate DDE conversation using System topic
      Channel = DDEInitiate("EXCEL", "System")
      ' Open workbook file
      DDEExecute Channel, "[OPEN(" + Q$ + "C:\EXCEL\BOOK1.XLS" + Q$ + ")]"
      ' Initiate DDE conversation using open workbook file
      Channel2 = DDEInitiate("excel", "C:\EXCEL\BOOK1.XLS")
      ' Insert data in workbook
      DDEPoke Channel2, "R1C1", "Total: $1,434"
      DDETerminate Channel
      DDETerminate Channel2
   End Sub


0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now