is there any way to programmaticaly add an hyperlink to the selected text in a MS Word Add-In?
Thanks in advance.
The code below converts selected text into a hyperlink which points to the Microsoft site:
Microsoft.Office.Interop.Word.Range currentRange = Globals.ThisAddIn.Application.Selection.Range;
if (currentRange != null)
{
Microsoft.Office.Interop.Word.Hyperlink hp = (Microsoft.Office.Interop.Word.Hyperlink)
currentRange.Hyperlinks.Add(currentRange, "http://www.microsoft.com");
}
The actual text of the hyperlink,by default, will be your selected text. If you need this text to be of different value, for instance - the actual url address, you can simply change the TextToDisplay property:
hp.TextToDisplay = "http://www.microsoft.com";
I'm not sure exactly how dynamic your logic needs to be but I believe the above example will give you a push in the right direction.
If you are wanting to do this in VBA, it's
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, ...
Sytnax:
expression.Add(Anchor, Address, SubAddress, ScreenTip, TextToDisplay, Target)
Related
When editing a vertex I would like to substitute the vertex symbol with SimpleMarkerSymbol and a TextSymbol but that appears to be impossible. Any suggestions on how I could do this? I want the appearance of dragging something like this (text + circle):
After taking some time to look at the API I've come to the conclusion it is impossible. Here is my workaround:
editor.on("vertex-move", args => {
let map = this.options.map;
let g = <Graphic>args.vertexinfo.graphic;
let startPoint = <Point>g.geometry;
let tx = args.transform;
let endPoint = map.toMap(map.toScreen(startPoint).offset(tx.dx, tx.dy));
// draw a 'cursor' as a hack to render text over the active vertex
if (!cursor) {
cursor = new Graphic(endPoint, new TextSymbol({text: "foo"}));
this.layer.add(cursor);
} else {
cursor.setGeometry(endPoint);
cursor.draw();
}
})
You could use a TextSymbol to create a point with font type having numbers inside the circle. Here is one place where you can find such font. http://www.fontspace.com/the-fontsite/combinumerals
Wont be exactly as shown in the image but close enough. Also some limitation it wont work with IE9 or lower (this is as per esri documentation, as I am using halo to get the white border).
Here is the working Jsbin : http://jsbin.com/hayirebiga/edit?html,output use point of multipoint
PS: I have converted the ttf to otf and then added the font as base64, which is optional. I did it as I could not add the ttf or otf to jsbin.
Well, Achieve this seems impossible so far however ArcGIS JS API provides a new Application/platform where you can generate single symbol online for your applications.
We can simply create all kind of symbols(Provide by ESRI) online and it gives you on the fly code which you just need to paste in your application.
This will help us to try different type of suitable symbols for the applications.
Application URL: https://developers.arcgis.com/javascript/3/samples/playground/index.html
Hoping this will help you :)
In Writer, I would like to search for some text and when found position the view to the top of the view/window.
Using the following code,
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "SearchItem.SearchString"
args1(0).Value = ":"
dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())
the view changes and it shows the selection but it is not in any particular place. I want it to be at the top of the window/view.
I've also found elsewhere the use of ThisComponent.currentController.getViewData() and restoreViewData(). So I experimented and determined how to change the data returned in order to get a vertical scroll but nothing happens. For example...
vd = ThisComponent.currentController.getViewData()
vdParts = Split(vd, ";")
vdParts(6) = CLng(vdParts(6)) + 1000
vd = join(vdParts, ";")
ThisComponent.currentController.restoreViewData(vd)
Any suggestions?
PS: I am running version 5.0.5.2 on Windows 7 x64
Spreadsheets have View Panes that can be manipulated, but it does not look like there is a similar interface in Writer.
Instead, use the View Cursor to go down one or two pages, then move back to the location of the search result.
Also, do not use the dispatcher for the search. Use the API instead, like in section 7.14 of Andrew Pitonyak's macro document.
I would like to be able to add the page numbers in a word document to the header.
I have found some links that display the code in visual basic, but no matter what i try, i keep getting errors. It keeps telling me the either "sections" or "headers" or "footers" is not a supported automation object.
Any help would realy be great. Thank You.
Links:
http://blogs.technet.com/b/heyscriptingguy/archive/2006/05/10/how-can-i-add-centered-page-numbers-to-the-footer-of-a-word-document.aspx
http://msdn.microsoft.com/en-us/library/office/ff194253(v=office.14).aspx
I Tried addapting the link's code with no success:
wrdDoc.ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).PageNumbers.Add
and if possible please how to allign the page number right.
Use [] instead of () for indexes
//Headers[wdHeaderFooterPrimary] = Headers[1]
//Add possible values:
//wdAlignPageNumberCenter = 1
//wdAlignPageNumberInside = 3
//wdAlignPageNumberLeft = 0
//wdAlignPageNumberOutside = 4
//wdAlignPageNumberRight =2
wrdDoc.Sections[1].Headers[1].PageNumbers.Add(1); //example with center alignment
wrdDoc.Sections[1].Headers[1].PageNumbers.Add(2); //example with right alignment
I am able to show the range explorer and also the numberformat category of it in my windows app using its default constructor, but really dont know how to retrieve the selected number format and pass it to the form's textbox. I am very new to spreadsheetGear. Can anyone help in using the range explorer. Thanks in Advance
Short answer: After the range explorer is closed, set the the Text property of the text box to the NumberFormat property of one of the cells within the range used in the range used in the RangeExplorer constructor.
textbox1.Text = worksheet.Cells["A1"].NumberFormat;
Longer answer: You can set up the range explorer like the code below.
// Select a range of cells.
workbookView.ActiveWorksheet.Cells["A1:C3"].Select();
// Get the active workbook set.
SpreadsheetGear.IWorkbookSet workbookSet = workbookView.ActiveWorkbookSet;
// Create the Range Explorer which operates on the current range selection.
SpreadsheetGear.Windows.Forms.RangeExplorer explorer
= new SpreadsheetGear.Windows.Forms.RangeExplorer(workbookSet);
// Set up some FormClosed event handler.
explorer.FormClosed
+= new System.Windows.Forms.FormClosedEventHandler(rangeExplorer_FormClosed);
// Display the Range Explorer to the user.
explorer.Show(workbookView);
In the FormClosed event handler, you can get the NumberFormat for anywhere inside the range used in the RangeExplorer constructor. If your text box is called textbox1, it would look like this.
private void rangeExplorer_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
{
workbookView.GetLock();
try
{
SpreadsheetGear.IWorksheet worksheet = workbookView.ActiveWorksheet;
textbox1.Text = worksheet.Cells["A1"].NumberFormat;
}
finally
{
workbookView.ReleaseLock();
}
}
I am creating a custom field in SharePoint 2007. I have seen other solutions where the current site URL was default value of a text field.
How can I get this current site URL?
I have got one answer whiches states that I shall use JavaScript, but where do I put the script?
I hope you can help.
BR
To answer 1
I am new to SharePoint and am not quiet sure where to put the java script. Normaly i just give the initial value to the field in the FieldEditor.cs file but how can I do this with the javascript?
Here follows a picute of my files.
I have tried to put it into FiledEditor.cs but this results in the value of myString is written in the top of the web page.
Here is my current code:
string myScript = "var currentUrl = document.URL; LabelLookupFieldTargetURLText.Text = currentUrl;";
Page.ClientScript.RegisterClientScriptBlock(LabelLookupFieldTargetURLText.GetType(), "LabelLookupFieldTargetURLTextJavaScript", myScript);
I found the answer my self. I don't need to use a java script. I can just use SPContext.Current.Site.Url
use javascript:
var nowUrl = document.URL;
yourTextfiled.value = nowUrl;
you can read this:http://www.w3schools.com/jsref/dom_obj_document.asp