Found a way to change the color of text in an EXCEL file.
1. Create a macro within EXCEL. I created one to change the
text color by recording it. I called it "Macro1". I was using a
worksheet called "Book1".
2. From SwiftForth, select the cell you wish to run the macro on:
SERVER EXCEL
TOPIC BOOK1
S\" [SELECT(\"R1C1\")]"
DDE-INIT DDE-EXECUTE DDE-END
This will move the pointer to the 1st cell. \"R5C21\" would move
it to the 21st cell in the 5th row.
3. Run the macro on the cell:
SERVER EXCEL
TOPIC BOOK1
S\" [RUN(\"Macro1\")]"
DDE-INIT DDE-EXECUTE DDE-END
The macro name is case sensitive --- using \"MACRO1\" changes the
text color but destroys the cell data.
The idea for this approach came from MSDN article Q103087
"How to Send Macro Commands to MS Excel Using DDEEXECUTE()"
The version of DDE-EXECUTE used was:
: DDE-EXECUTE ( addr n -- )
( a n) CONV HITEM CF_TEXT XTYP_EXECUTE 5000 0 DdeClientTransaction
DdeFreeDataHandle DROP ;
Brad McClarren
----- Original Message -----
From: "Richard Owlett" <rowlett_at_atlascomm.net>
To: <sftalk_at_forth.com>
Sent: Wednesday, December 06, 2000 5:08 PM
Subject: Re: [sftalk] XTYP_EXECUTE, DdeClientTransaction, and EXCEL
> If using MS Excel refer to MS Acess Help files -- its the Microsoft way.
>
> Use of 'System' and 'Topic' may give hint as to wheter you CAN/CANNOT
perform
> the desired operation via DDE.
> Below I've quoted a portion of the MS Access Help File which may give you
> inspiration ;]
>
> "
> The System Topic
>
> The System topic is a standard topic for all Microsoft Windows-based
> applications. It supplies information about the other topics supported by
the
> application. To access this information, your code must first call the
> DDEInitiate function with "System" as the topic argument, and then execute
the
> DDERequest statement with one of the following supplied for the item
argument.
>
> Item Returns
> SysItems A list of items supported by the System topic in Microsoft
Access.
> Formats A list of the formats Microsoft Access can copy onto the
Clipboard.
> Status "Busy" or "Ready".
> Topics A list of all open databases.
> The following example demonstrates the use of the DDEInitiate and
DDERequest
> functions with the System topic:
>
> ' In Visual Basic, initiate DDE conversation with Microsoft Access.
> Dim intChan1 As Integer, strResults As String
> intChan1 = DDEInitiate("MSAccess", "System")
> ' Request list of topics supported by System topic.
> strResults = DDERequest(intChan1, "SysItems")
> ' Run OpenDatabase action to open Northwind.mdb.
> ' You may need to change this path to point to actual location
> ' of Northwind sample database.
> DDEExecute intChan1, "[OpenDatabase C:\Access\Samples\Northwind.mdb]"
> "
>
>
> Brad McClarren wrote:
>
> > Thanks Glenn,
> >
> > Finding the correct command and format is key as you say. Looks like
I'm
> > out of the world of Swiftforth and into that of EXCEL.
> >
> > Brad McClarren
> >
> > ----- Original Message -----
> > From: "Glenn Dixon" <DIXONG_at_iomega.com>
> > To: <sftalk_at_forth.com>
> > Sent: Tuesday, December 05, 2000 11:33 AM
> > Subject: Re: [sftalk] XTYP_EXECUTE, DdeClientTransaction, and EXCEL
> >
> > Brad,
> >
> > Your command selects the desired cell, but does not perform a command on
it.
> > All DDE transactions to Excel must start with a command. Your example
uses
> > the command WORKSHEETS, and selects the
> > specified worksheet and cell. That's all this particluar command does.
> > Though I'm not sure, the Font,ColorIndex=3 is probably ignored.
> >
> > The reason your string appears in the selected cell is because a string
sent
> > without a valid commandword preceding it
> > is interpreted as string intput by Excel.
> >
> > I do not know the command to change the font color index, but I can help
> > with the command to change a cell's value
> >
> > It is:
> >
> > [FORMULA(2.00000E6,"R001C001")]
> >
> > That is, the commandword FORMULA, and then parameters in parenthesis.
This
> > will put the number 2.0E6 in the cell at row 1 column 1. Note that
columns
> > are numbers and not letters in DDE.
> >
> > A real formula with math operations, variables and cell values or ranges
in
> > it will also work.
> > The second parameter (row and column) can be omitted if previous
commands
> > have all ready selected the desired cell.
> >
> > All DDE commands must start with a commandword. The trick is finding
the
> > right one, and the correct format for the parameters that follow.
> >
> > Hope this helps,
> >
> > Glenn Dixon
> >
> > >>> bmcclarr_at_comanche.redstone.army.mil 12/05/00 05:40AM >>>
> > Mike and Charles,
> >
> > Thank you very much for your replies. I tried both suggestions. In
each
> > case, the command I wish to execute within EXCEL is written into the
cell as
> > text. This means I'm getting there, but with the wrong action --- an
> > improvement. You got me onto the right track!
> >
> > Brad McClarren
> >
> > From: "Mike Ghan" <mikeg_at_logix-controls.com>
> > To: <sftalk_at_forth.com>
> > Sent: Monday, December 04, 2000 4:15 PM
> > Subject: [sftalk] XTYP_EXECUTE, DdeClientTransaction, and EXCEL
> >
> > > I believe VBA (Visual Basic for Apps) prefers caps for the range. Try
> > >
> > > Z\" WORKSHEETS(\"SHEET1\").Range(\"A1:C1\").Font.ColorIndex=3"
> > >
> > > I've not tested this, but our VBA guy believes this will take care of
> > > it.
> > >
> > > Hope it helps,
> > >
> > > Mike
> >
> > ----- Original Message -----
> > From: "Charles Melice" <mail_at_forthcad.com>
> > To: <sftalk_at_forth.com>
> > Sent: Monday, December 04, 2000 5:13 PM
> > Subject: Re: [sftalk] XTYP_EXECUTE, DdeClientTransaction, and EXCEL
> >
> > > On Mon, 04 December 2000, "Brad McClarren" wrote:
> > >
> > > [...]
> > >
> > > > : DDE-EXECUTE ( addr n -- )
> > > > ( a n) CONV HITEM CF_TEXT XTYP_EXECUTE 5000 0
DdeClientTransaction
> > > > DdeFreeDataHandle DROP ;
> > >
> > > [...]
> > >
> > > > Anybody have a pointer or two?
> > >
> > > Try the following: ( just "1+" appended )
> > >
> > > : DDE-EXECUTE ( addr n -- )
> > > ( a n) 1+ CONV HITEM CF_TEXT XTYP_EXECUTE 5000 0
DdeClientTransaction
> > > DdeFreeDataHandle DROP ;
> > >
> > > Regards,
> > > Charles Melice
> > >
> > >
> > >
> > > _______________________________________________
> > > Sftalk mailing list Sftalk_at_forth.com
> > > Visit Sftalk on the web at
http://www.forthinc.com/mailman/listinfo/sftalk
> >
> > _______________________________________________
> > Sftalk mailing list Sftalk_at_forth.com
> > Visit Sftalk on the web at
http://www.forthinc.com/mailman/listinfo/sftalk
> >
> > _______________________________________________
> > Sftalk mailing list Sftalk_at_forth.com
> > Visit Sftalk on the web at
http://www.forthinc.com/mailman/listinfo/sftalk
> >
> > _______________________________________________
> > Sftalk mailing list Sftalk_at_forth.com
> > Visit Sftalk on the web at
http://www.forthinc.com/mailman/listinfo/sftalk
>
>
> _______________________________________________
> Sftalk mailing list Sftalk_at_forth.com
> Visit Sftalk on the web at http://www.forthinc.com/mailman/listinfo/sftalk
Received on Thu Dec 07 2000 - 10:20:27 PST
Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!
This archive was generated 09-Feb-2012. Archive updated nightly.