I've been searching for this for hours, but could not find appropriate approach to do so. On MSDN, they suggest using Address and SubAddress to locate a slide in a Presentation, but this failed its purpose.
So my question is, how to add a hyperlink to a slide in the same Presentation?
Finally I've figured it out, and since there's lack of resources, I would like to post my solution.
Interestingly, to add a hyperlink to a slide inside the same presentation, you need to leave Address property blank, and set its SubAddress to be a string in a format: "yourSlideID,yourSlideIndex,yourSlideName".
For example, you want to add a hyperlink to a slide with slide ID 256, slide index 1, slide name "Slide 1", to a shape, do this:
var mouseOnClickAction = shape.ActionSettings[PpMouseActivation.ppMouseClick];
mouseOnClickAction.Action = PpActionType.ppActionNamedSlideShow;
mouseOnClickAction.Hyperlink.Address = null;
mouseOnClickAction.Hyperlink.SubAddress = "256,1,Slide 1";
Hope this helps everybody :D
Related
I have added below code
ChartSeries series1 = new ChartSeries("August",ChartSeriesType.Column);
// Add points to series1.
//....
//....
// Here, the text is given explicitly.
ChartSeries series2 = new ChartSeries("June",ChartSeriesType.Column);
series2.Text = "JuneSales";
How to get the 'JuneSales' text first then ColumnBar later.
Currently i am getting First the ColumnBar and then 'JuneSales' text.
Thanks in advance
Greetings from Syncfusion,
We have analyzed your query. And we are having IconAlignment property to position the legend item icons. To place the text after the legend symbol, you can set alignment as Right for IconAlignment.
Please find the below code snippet to achieve this requirement,
chart.Legend.Items[0].IconAlignment = LeftRightAlignment.Right;
chart.Legend.Items[1].IconAlignment = LeftRightAlignment.Right;
Screenshot:
Sample for your reference, can be found from below link,
http://www.syncfusion.com/downloads/support/directtrac/general/ze/legendText1476620276
Kindly revert us, if you have any concerns.
Regards,
Baby.
I have implemented a hyperlink interface; when the user selects text in the document and then clicks a button from my Word Add-in, there is a comment box that is pre-filled with text added to this selection.
However, I want to include a hyperlink that is clickable to bring the user to a Google Doc and this link should be at the end of the comment box. This is what I have tried so far:
Hyperlink link = new Link();
link.Address = (String) oAddress;
link.SubAddress = (String) oSubAddress;
link.TextToDisplay = "more";
selection.Comments.Add(rng2, comment + link)
It looks like you need to create a collection of Hyperlinks from your current document, then add your hyperlink to it.
Below code should highlight everything inside your comment.
// Select the element you want to apply the hyperlink to - you will have to use the Find method
Microsoft.Office.Interop.Word.Range currentRange = myDoc.Comments[0].Range
if (currentRange != null)
{
Microsoft.Office.Interop.Word.Hyperlink hp = (Microsoft.Office.Interop.Word.Hyperlink)
// This line is what you are missing
currentRange.Hyperlinks.Add(currentRange, "http://www.microsoft.com");
}
Credit to https://stackoverflow.com/a/8665770/5209435.
You can use the above as a base before using the Find method to narrow to find the text that you want to hyperlink and just apply it to the selected text. See this question.
I'm trying to add a rich text content control around the user's selected text in a Word document.
I'm new to VSTO and Content Controls so i'm using the MSDN examples as a baseline. The example shows this, which adds the Content Control at the chosen position:
private void AddRichTextControlAtSelection()
{
word.Document currentDocument = Globals.ThisAddIn.Application.ActiveDocument;
currentDocument.Paragraphs[1].Range.InsertParagraphBefore();
currentDocument.Paragraphs[1].Range.Select();
Document extendedDocument = Globals.Factory.GetVstoObject(currentDocument);
richTextControl1 = extendedDocument.Controls.AddRichTextContentControl("richTextControl1");
richTextControl1.PlaceholderText = "Enter your first name";
}
However i want the Content Control to wrap around the user's selected text. Any help, please?
What you found is one possibility. More efficient and "cleaner" (IMO) would be to use the constructor that accepts a RANGE object and pass the Range. If you want the user's selection then
richTextControl1 = extendedDocument.Controls.AddRichTextContentControl(extendedDocument.Parent.Selection.Range, "richTextControl1");
//the Parent of a Document is the Word.Application
//Selection is a dependent of the Word.Application
Otherwise, building on your code sample:
richTextControl1 = extendedDocument.Controls.AddRichTextContentControl(currentDocument.Paragraphs[1].Range, "richTextControl1");
Note that if you don't need to work with VSTO's extensions of the Content Controls you don't need to go through the GlobalFactory steps, you can simply insert the "interop" versions of the Content Controls.
Simple fix in the end: currentDocument.ActiveWindow.Selection.Range.Select();
I know how to show page numbers and how to align them in footer. However my problem is that my Footer contains some custom text which should be left aligned and page number should be aligned to right corner.
string footer = "My custom footer";
Paragraph footerParagraph = section.Footers.Primary.AddParagraph(footer);
footerParagraph.AddTab();
footerParagraph.AddPageField();
Above will generate "My custom footer 1" for page 1, I need page nmuber to be right at the right most corner of the page. I can add extra spaces or tab but thought there must be a clean way to achieve this. Thanks.
Keep it Simple: Use a Tab Stop
The best way to do this is the same as you would do in most word processing tools: with a right-aligned tab-stop, placed on the right margin of the page. This is pretty straight forward, but I couldn't find the "full" solution anywhere, so here's what you need:
// Grab the current section, and other settings
var section = documentWrapper.CurrentSection;
var footer = section.Footers.Primary;
var reportMeta = documentWrapper.AdminReport.ReportMeta;
// Format, then add the report date to the footer
var footerDate = string.Format("{0:MM/dd/yyyy}", reportMeta.ReportDate);
var footerP = footer.AddParagraph(footerDate);
// Add "Page X of Y" on the next tab stop.
footerP.AddTab();
footerP.AddText("Page ");
footerP.AddPageField();
footerP.AddText(" of ");
footerP.AddNumPagesField();
// The tab stop will need to be on the right edge of the page, just inside the margin
// We need to figure out where that is
var tabStopPosition =
documentWrapper.CurrentPageWidth
- section.PageSetup.LeftMargin
- section.PageSetup.RightMargin;
// Clear all existing tab stops, and add our calculated tab stop, on the right
footerP.Format.TabStops.ClearAll();
footerP.Format.TabStops.AddTabStop(tabStopPosition, TabAlignment.Right);
The hardest part of this, is figuring out what your tab stop position should be. Because I'm boring and really like encapsulation, I dynamically calculate the tab stop position, based on the page width, less the horizontal page margins. However, getting the current page width wasn't as easy as I'd thought it'd be, because I'm using PageFormat to set the page dimensions.
Next Challenge: Getting Your Page Width, Dynamically
First, I really hate having tightly coupled code (think: fan-in and fan-out), so even though I know at this point in time what my page width is, even to the point of hard-coding it, I still want to hard code it in only a single place, then refer to that one place everywhere else.
I keep a custom "has-a"/wrapper class to keep this stuff encapsulated into; That's documentWrapper in my code here. Additionally, I don't expose any of the PDFSharp/MigraDoc types to the rest of my application, so I'm using ReportMeta as a way to communicate settings.
Now for some code. When I setup the section, I'm using the MigraDoc PageFormat to define the size of my page for the current section:
// Create, and set the new section
var section = documentWrapper.CurrentDocument.AddSection();
documentWrapper.CurrentSection = section;
// Some basic setup
section.PageSetup.PageFormat = PageFormat.Letter; // Here's my little bit of hard-coding
Unit pageWidth, pageHeight;
PageSetup.GetPageSize(PageFormat.Letter, out pageWidth, out pageHeight);
var reportMeta = documentWrapper.AdminReport.ReportMeta;
if (reportMeta.PageOrientation == AdminReportMeta.ORIENT_LANDSCAPE)
{
section.PageSetup.Orientation = Orientation.Landscape;
documentWrapper.CurrentPageWidth = pageHeight;
}
else
{
section.PageSetup.Orientation = Orientation.Portrait;
documentWrapper.CurrentPageWidth = pageWidth;
}
What's really important here, is that I'm storing the CurrentPageWidth, this becomes really important when setting up our tab stops. The CurrentPageWidth property, is simply a MigraDoc Unit type. I am able to determine what this is by using MigraDoc's PageSetup.GetPageSize with my chosen PageFormat.
A single tab will do. Create a right-aligned tab at the right-most position.
You can set the tab stops for the footer style (recommended) or for the paragraph.
Code snippet modifying a style:
var style = document.Styles[StyleNames.Footer];
style.ParagraphFormat.TabStops.ClearAll();
style.ParagraphFormat.TabStops.AddTabStop(Unit.FromMillimeter(158), TabAlignment.Right);
You could try something like this:
Paragraph paragraph = new Paragraph();
paragraph.Format.Alignment = ParagraphAlignment.Left;
paragraph.AddText("My custom footer: ");
Paragraph paragraph2 = new Paragraph();
paragraph2.Format.Alignment = ParagraphAlignment.Right;
paragraph2.AddText(" Page # ");
paragraph2.AddPageField();
section.Footers.Primary.Add(paragraph);
section.Footers.Primary.Add(paragraph2);
I'm working on a screen reader and till now I was successful to get the whole text of a page in IE. But I have no idea how to get the current visible part of page or to get the current paragraph that is under the cursor in IE.
I don't mean to give me the code, but just to recommend me if there is a way to do it using APIs or similar things.
from what I found I think it’s not doable using Accessibility APIs.
I GREATLY appreciate any ideas and helps.
If you're application is a WinForms app, you might want to look into using the Browser control. I'm still a bit unclear about what you're looking for, but I think the browser control is what you'll need.
Here's a similar question that may point you in the right direction:
C# WebBrowser control -- Get Document Elements After AJAX?
To access the contents of a paragraph when the cursor moves over it you could use javascript:
var oP = document.body.getElementsByTagName('p');
for (var i = 0; i < oP.length; i++) {
oP[i].onmouseover = function() {
var content = oP[i].innerHTML;
// Do whatever you want with content.
};
}
This will fire the onMouseOver event when cursor moves over a paragraph and you will then be able to read it's content.