Hello Dave,
I think the PowerPoint just wants a html string in the <!--StartFragment-->
and <!--EndFragment-->. In my side, I have used,
"<Table><TR><TD>Item 6</TD><TD>Item 7</TD></TR><TR><TD>Item 10</TD><TD>Item
11</TD></TR></Table>"
The following codes can let the end user drag and drop a table into the
PowerPoint slide.
private void label1_MouseDown(object sender, MouseEventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
string htmlFragment = "<Table><TR><TD>Item 6</TD><TD>Item
7</TD></TR><TR><TD>Item 10</TD><TD>Item 11</TD></TR></Table>";
// Builds the CF_HTML header. See format specification here:
//
http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/clipb
oard/htmlclipboard.asp
// The string contains index references to other spots in the
string, so we need placeholders so we can compute the offsets.
// The <<<<<<<_ strings are just placeholders. We'll backpatch
them actual values afterwards.
// The string layout (<<<) also ensures that it can't appear in
the body of the html because the <
// character must be escaped.
string header =
@"Format:HTML Format
Version:1.0
StartHTML:<<<<<<<1
EndHTML:<<<<<<<2
StartFragment:<<<<<<<3
EndFragment:<<<<<<<4
StartSelection:<<<<<<<3
EndSelection:<<<<<<<3
";
string pre =
@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN"">
<HTML><HEAD></HEAD><BODY><!--StartFragment-->";
string post = @"<!--EndFragment--></BODY></HTML>";
sb.Append(header);
int startHTML = sb.Length;
sb.Append(pre);
int fragmentStart = sb.Length;
sb.Append(htmlFragment);
int fragmentEnd = sb.Length;
sb.Append(post);
int endHTML = sb.Length;
// Backpatch offsets
sb.Replace("<<<<<<<1", To8DigitString(startHTML));
sb.Replace("<<<<<<<2", To8DigitString(endHTML));
sb.Replace("<<<<<<<3", To8DigitString(fragmentStart));
sb.Replace("<<<<<<<4", To8DigitString(fragmentEnd));
Clipboard.Clear();
Clipboard.SetText(sb.ToString(), TextDataFormat.Html);
if (e.Button == MouseButtons.Left)
{
this.DoDragDrop(new
DataObject(DataFormats.Html,sb.ToString()), DragDropEffects.Copy);
Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange.Top = 20;
Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange.Left = 20;
}
And now, I can see your problem, but not exactly same with yours. In my
side, when dragging and dropping, the dropped table always goes to the
center of the slide instead of the upper left corner. Is this the problem
you are concerning now?
I find that we can set the ShapeRange's location by setting the Top and
Left property as in the above codes. But it seems a difficult thing to get
the PowerPoint coordinate from the caret cursor location. I am doing some
more research on this and will update to you as soon as I found an approach.
Have a good day!
Best regards,
Ji Zhou (
[email protected], remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.