Toxter

Hello everyone.

I'm developing Word 2007 AddIn in C#.

What I'm trying to implement last couple of days is drag&drop from my

custom task pane to Word document.

I'm trying to drag&drop and when object is dropped to create MergeField.

All I could do so far is to drag&drop string (text).

So, the main question is: Can I format text which will be dropped to Word in a way

that Word will automatically convert to MergeField

Or, can I somehow perform drag&drop which will create MergeField

Thank you.



Re: Visual Studio Tools for Office Create MergeField from string

Toxter

Any suggestions I've searched for drag&drop on this forum, but with no luck

I would appreciate any help.

Thank you.





Re: Visual Studio Tools for Office Create MergeField from string

Ji Zhou ¨C MSFT

Hi Toxter,

As far as I know, we cannot capture the drop-event via VSTO, even in any technology using Word Object Model. So, when you drop anything on surface of Word, no matter it is text, picture or other objects, Word performs in its own way.

Your objective cannot be achieved through VSTO. I am not very sure if Windows API can be competent for your job, but that is complicated and off topic in the VSTO forum.

Thanks

Ji






Re: Visual Studio Tools for Office Create MergeField from string

Toxter

Hmm I was afraid of that.

But WinAPI is not foreign to me. If you could be so kind and put some hints of what to use or maybe some
link I would very much appreciate it.

Thank you.




Re: Visual Studio Tools for Office Create MergeField from string

dunean

I know from VSTO that it is possible to create MergeFields, and although I have not tried the drag&drop idea, I have added mergefields to documents using C# add-ins. A suggestion would be for you to format the text-string in such a way that you can scan the document after it has been dropped and convert the text into a mergefield. For example, let's say you wish to add an Address_Line_1 mergefield. Drop the text **Address_Line_1** (something unique) and then search for it in ActiveDocument. Select it and then add the mergefield in the selected range, with the name of the text, minus the asterisks.





Re: Visual Studio Tools for Office Create MergeField from string

Toxter

Hello dunean,

You said: "Drop the text **Address_Line_1** (something unique) and then search for it in ActiveDocument."

Yes, but how can I know that something is dropped to Document

Thanks.





Re: Visual Studio Tools for Office Create MergeField from string

dunean

Not knowing quite how you are implementing the solution, I can't say exactly what is acceptable, but if indeed you cannot catch the onDrop event, then I suggest maybe adding a post "drop" processing button. Once the user has added a field (or multiple fields for that matter) then work through the document and convert all fields found. I am looking into the Drag&Drop thing myself now, out of curiosity, and will post if I find anything new.





Re: Visual Studio Tools for Office Create MergeField from string

Toxter

Hello dunean,

My Add-In will have custom task pane, which has a TreeView. I need to implement drag&drop from TreeView on Word Document. So "post drop button" is not acceptable for users. Any suggestions on how to "catch" drop event

Thank you.