CW -> EXCEL Syntax 
Author Message
 CW -> EXCEL Syntax

I am trying to open a text file I've created in comma delimited text format
in an Excel worksheet. After studying the Docs and reading the CW Journal
articles on DDE, I came up with this code...

ExcelExport                  ROUTINE
  StartedExcel = False
  ExcelDDEChan = DDECLIENT('Excel','SYSTEM')
  If ExcelDDEChan < 1
     RUN('C:\MSOFFICE\EXCEL\EXCEL.EXE /n')
     ExcelDDEChan = DDECLIENT('Excel','SYSTEM')
     If ExcelDDEChan < 1
        Message( 'Unable to start EXCEL DDE Session','Oops!')
     Else
        StartedExcel = True

DDEExecute(ExcelDDEChan,'[OPEN.TEXT("C:\RMS2001\DB\TEST.TXT",2,1,1,1,FALSE,F
ALSE,FALSE,TRUE,FALSE,FALSE,,)]')
        If Errorcode()
           Message( Errorcode() & ' ' & Error() )
        End !if
     End !if
  End !if

The problem is, Excel starts as expected but then I get a DDE error that
says DDE is unable to open the document.   The document DOES exist and I
would expect Excel to be able to find it. Anyone have any ideas?



Sat, 16 Sep 2000 03:00:00 GMT  
 CW -> EXCEL Syntax

Hi
The following is code that I use to open excel, create a file, save it and
then I close the channel.

I then start excel with the file name

Channel = DDECLIENT('Excel','System')
IF Channel < 1
  Message('Cannot Open Excel')
ELSE
RUN('Excel')
  Channel = DDECLIENT('Excel','System')
END
!Create new file and save it
DDEEXECUTE(Channel,'[NEW(1)]')
DDEEXECUTE(Channel, '[SAVE.AS("DTI.XLS",1,"", FALSE,"",FALSE)]')
DDECLOSE(Channel)
!****** Open file for data adding
Channel = DDECLIENT('Excel','DTI.XLS')

As you can see, I don't specify any parameters other than the filename. This
works for me..

Ciao


Quote:
>I am trying to open a text file I've created in comma delimited text format
>in an Excel worksheet. After studying the Docs and reading the CW Journal
>articles on DDE, I came up with this code...

>ExcelExport                  ROUTINE
>  StartedExcel = False
>  ExcelDDEChan = DDECLIENT('Excel','SYSTEM')
>  If ExcelDDEChan < 1
>     RUN('C:\MSOFFICE\EXCEL\EXCEL.EXE /n')
>     ExcelDDEChan = DDECLIENT('Excel','SYSTEM')
>     If ExcelDDEChan < 1
>        Message( 'Unable to start EXCEL DDE Session','Oops!')
>     Else
>        StartedExcel = True

>DDEExecute(ExcelDDEChan,'[OPEN.TEXT("C:\RMS2001\DB\TEST.TXT",2,1,1,1,FALSE,
F
>ALSE,FALSE,TRUE,FALSE,FALSE,,)]')
>        If Errorcode()
>           Message( Errorcode() & ' ' & Error() )
>        End !if
>     End !if
>  End !if

>The problem is, Excel starts as expected but then I get a DDE error that
>says DDE is unable to open the document.   The document DOES exist and I
>would expect Excel to be able to find it. Anyone have any ideas?



Sat, 16 Sep 2000 03:00:00 GMT  
 CW -> EXCEL Syntax

The reason I close the channel and then restart is that I get the error
"File name does not exsist" from excel if I don't do this.

I also don't try the DDEEXCEUTE method of starting excel as this also gives
me an error.

Hope this helps some ... I am as lost as you are with DDE .. I just know
what works for me.

Ciao

Quote:

>Hi
>The following is code that I use to open excel, create a file, save it and
>then I close the channel.

>I then start excel with the file name

>Channel = DDECLIENT('Excel','System')
>IF Channel < 1
>  Message('Cannot Open Excel')
>ELSE
>RUN('Excel')
>  Channel = DDECLIENT('Excel','System')
>END
>!Create new file and save it
>DDEEXECUTE(Channel,'[NEW(1)]')
>DDEEXECUTE(Channel, '[SAVE.AS("DTI.XLS",1,"", FALSE,"",FALSE)]')
>DDECLOSE(Channel)
>!****** Open file for data adding
>Channel = DDECLIENT('Excel','DTI.XLS')

>As you can see, I don't specify any parameters other than the filename.
This
>works for me..

>Ciao



>>I am trying to open a text file I've created in comma delimited text
format
>>in an Excel worksheet. After studying the Docs and reading the CW Journal
>>articles on DDE, I came up with this code...

>>ExcelExport                  ROUTINE
>>  StartedExcel = False
>>  ExcelDDEChan = DDECLIENT('Excel','SYSTEM')
>>  If ExcelDDEChan < 1
>>     RUN('C:\MSOFFICE\EXCEL\EXCEL.EXE /n')
>>     ExcelDDEChan = DDECLIENT('Excel','SYSTEM')
>>     If ExcelDDEChan < 1
>>        Message( 'Unable to start EXCEL DDE Session','Oops!')
>>     Else
>>        StartedExcel = True

>>DDEExecute(ExcelDDEChan,'[OPEN.TEXT("C:\RMS2001\DB\TEST.TXT",2,1,1,1,FALSE
,
>F
>>ALSE,FALSE,TRUE,FALSE,FALSE,,)]')
>>        If Errorcode()
>>           Message( Errorcode() & ' ' & Error() )
>>        End !if
>>     End !if
>>  End !if

>>The problem is, Excel starts as expected but then I get a DDE error that
>>says DDE is unable to open the document.   The document DOES exist and I
>>would expect Excel to be able to find it. Anyone have any ideas?



Sat, 16 Sep 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Searching for a Parser with MS-EXCEL-Syntax/Grammar

2. CW 2.0 and DDE-Excel

3. Printing Word/Excel from a CW app

4. Excel internal format & CW

5. OLE with Excel (CW 2.003)

6. Using DDE:s CW / Excel

7. cw and excel

8. Fw: [cw-talk] Crystal VBX Syntax to use SelectionFormula Property

9. CW 2.003, Remove, Copy syntax..

10. Implementing letrec-syntax using only let-syntax and syntax-rules

11. HELP>>>>>>>Fortran-Pascal Linking

12. >>>>>>>FROM SMTK TO C++

 

 
Powered by phpBB® Forum Software