Re: Dragging data to Excel using DoDragDrop
- From: Peter Duniho <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Tue, 02 Oct 2007 00:52:31 -0700
Bruce_Stough wrote:
I am currently using Control.DoDragDrop to drop a text string into Excel. I use the following code
DataObject dd = new DataObject();
dd.SetData(DataFormats.Text,"\\\\ws-it-bstough\\ShareFolder\\Test.wav");
DoDragDrop(dd,DragDropEffects.Copy);
The code works as expected but it will always populate into Excel as a string literal and not as a link to the audio file. If I type the path into a excel the link appears correctly. I am using a windows form in C# to initiate the drag request.
Any Suggestions ?
I'm not sure you're going to be able to do that using the Text data format. I've noticed in the past that Excel won't auto-recognize URLs, UNC paths, etc. except when parsing direct user-input.
If you were using automation, there might be a way to get it to do the recognition explicitly, but AFAIK you can't hook that up to a simple D&D operation.
The one thing that does come to mind is the possibility of creating a ..lnk format object for the DataObject. That might be in a format Excel would recognize and paste in as an actual link.
Of course, how exactly to do that doesn't come immediately to mind. I guess you'll have to look into that yourself. But it's a thought anyway. :)
Pete
.
- References:
- Dragging data to Excel using DoDragDrop
- From: Bruce_Stough
- Dragging data to Excel using DoDragDrop
- Prev by Date: Re: Writing bitmap properties?
- Next by Date: Re: Windows Service Question
- Previous by thread: Dragging data to Excel using DoDragDrop
- Next by thread: Re: Dragging data to Excel using DoDragDrop
- Index(es):
Relevant Pages
|