By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,799 Members | 1,376 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,799 IT Pros & Developers. It's quick & easy.

MSFLXGRD and Excel

P: n/a
I am trying to copy the cell contents in an MSFLXGRD control (using
VB5) into Excel, retaining the foreground colors of the text and
numbers.

I have tried using the Clipboard.SetText msflxgrd1.Clip command, but
that ignores the colors.

I have tried to write rtf-coded text to the clipboard using:

Clipboard.SetText rtf_Text, -16639

where rtf_text is text with rtf commands imbedded, but that does not
work (even though it appears fine in Word), even though the SetText
Method notes say that:

object.SetText data, format

Settings for format are:
---------------------------------
vbCFRTF &HBF01 RichText Format

should copy text to the clipboard in rtf format. Excel does not
recognize that anything is on the clipboard when this instruction is
executed.

All I want to do is highlight cells in the MSFLXGRD with the left
mouse button, then write that data to the clipboard (including
foreground colors) using the Mouse UP Event, so I can then go to Exel
and paste the cells into a workbook in any location I desire.
Thank you.

Oct 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Otie" <ot*********@adelphia.net> wrote in message
news:3O********************@adelphia.com...
I am trying to copy the cell contents in an MSFLXGRD control (using
VB5) into Excel, retaining the foreground colors of the text and
numbers.

I have tried using the Clipboard.SetText msflxgrd1.Clip command, but
that ignores the colors.

I have tried to write rtf-coded text to the clipboard using:

Clipboard.SetText rtf_Text, -16639

where rtf_text is text with rtf commands imbedded, but that does not
work (even though it appears fine in Word), even though the SetText
Method notes say that:

object.SetText data, format

Settings for format are:
---------------------------------
vbCFRTF &HBF01 RichText Format

should copy text to the clipboard in rtf format. Excel does not
recognize that anything is on the clipboard when this instruction is
executed.

All I want to do is highlight cells in the MSFLXGRD with the left
mouse button, then write that data to the clipboard (including
foreground colors) using the Mouse UP Event, so I can then go to Exel
and paste the cells into a workbook in any location I desire.


I think you are out of luck. Try typing some text in Word, and make one word red
and another bold, then select the text and click Copy.
Switch to Excel, and click on Edit, Paste Special. On my machine, it is apparent
that Excel is only willing to paste as an embedded object, a metafile, or as
plain text without formatting. I don't think there is any provision in Excel to
paste text with formatting, especially into multiple cells.

You may have to write your own code using Excel automation, and transfer the
text cell by cell, and the formatting cell by cell.
Oct 19 '05 #2

P: n/a
>> You may have to write your own code using Excel automation, and
transfer the
text cell by cell, and the formatting cell by cell.

Yes, I believe you are right.

Here's where I am stumped.

Assumption: the spreadsheet I want to copy to is already open.

How do I set up something that takes the highlighted active cell in
the spreadsheet, then copies the grid data into it. I can do all the
copying no problem. What I can't seem to do is set up my objects, etc.
from an already-open spreadsheet. Below is some of the code I am
fiddling with:

Dim oApp as Excel.Application
Dim mybook As Workbook
Dim mysheet As Worksheet
Dim xl As Object

'don't know if I need to do this - I may just need Set oApp =
Excel.Application
Set xl = CreateObject("Excel.Sheet")

'but the spreadsheet is already open and the name could be anything
Set mybook = Application.Workbooks.Open(App.path &
"\Test.xls")

MsgBox "The name of the active sheet is " & ActiveSheet.Name

Set mysheet = mybook.Worksheets(ActiveSheet.Name)
Worksheets(ActiveSheet.Name).Activate
current_col% = ActiveCell.Column - 1
current_row% = ActiveCell.row - 1

I am okay from here, if I can get the above to work properly.
Thanks.
Odie


"Steve Gerrard" <my********@comcast.net> wrote in message
news:M5********************@comcast.com...

"Otie" <ot*********@adelphia.net> wrote in message
news:3O********************@adelphia.com...
I am trying to copy the cell contents in an MSFLXGRD control (using
VB5) into Excel, retaining the foreground colors of the text and
numbers.

I have tried using the Clipboard.SetText msflxgrd1.Clip command, but that ignores the colors.

I have tried to write rtf-coded text to the clipboard using:

Clipboard.SetText rtf_Text, -16639

where rtf_text is text with rtf commands imbedded, but that does not work (even though it appears fine in Word), even though the SetText Method notes say that:

object.SetText data, format

Settings for format are:
---------------------------------
vbCFRTF &HBF01 RichText Format

should copy text to the clipboard in rtf format. Excel does not
recognize that anything is on the clipboard when this instruction is executed.

All I want to do is highlight cells in the MSFLXGRD with the left
mouse button, then write that data to the clipboard (including
foreground colors) using the Mouse UP Event, so I can then go to Exel and paste the cells into a workbook in any location I desire.
I think you are out of luck. Try typing some text in Word, and make

one word red and another bold, then select the text and click Copy.
Switch to Excel, and click on Edit, Paste Special. On my machine, it is apparent that Excel is only willing to paste as an embedded object, a metafile, or as plain text without formatting. I don't think there is any provision in Excel to paste text with formatting, especially into multiple cells.

You may have to write your own code using Excel automation, and transfer the text cell by cell, and the formatting cell by cell.

Oct 19 '05 #3

P: 3
My biggest problem with reading data from an excel spreadsheet, from what I've seen, is you have to know what the first value in each cell is. I have wrote an app to stream data from excel to a csv but I couldn't find a way to do it with out knowing the first field name.
Oct 25 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.