Guest User

Untitled

a guest
Jan 18th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. var value = '=HYPERLINK("www.google.com", "Google")';
  2.  
  3. SpreadsheetApp.getActiveSpreadsheet()
  4. .getSheetByName("Sheet1")
  5. .getRange("A1")
  6. .setFormula(value);
  7.  
  8. DocumentApp.getActiveDocument().getBody().editAsText().insertText(0, "link text").setLinkUrl("www.google.com");
  9.  
  10. function insertLink() {
  11. var text = "link textn";
  12. var url = "www.google.com";
  13. DocumentApp.getActiveDocument().getBody().editAsText().insertText(0, text).setLinkUrl(0, text.length, url);
  14. }
  15.  
  16. function InsertLink(e)
  17. {
  18. var actSht = e.source.getActiveSheet();
  19. if (actSht.getName() == ['SheetName']){
  20.  
  21. var activeCell = actSht.getActiveCell(); //Detec the ActiveCell
  22.  
  23. //var activeCell = event.range;
  24. var activeCellValue = e.value;
  25.  
  26. var column = activeCell.getColumn();
  27. var colNums = [1]; //Columns, whose edit is considered
  28. if(colNums.indexOf(column) == -1) return; //If column other than considered then return
  29.  
  30. var row = activeCell.getRow();
  31. if(row < 2) return; //If header row then return
  32.  
  33. var length = String(activeCellValue).length;
  34.  
  35. if (!e.value)
  36. {
  37. activeCell.setValue()
  38. }
  39. else if(length > 4)
  40. {
  41. activeCell.setValue('=HYPERLINK' + '("http://otrs/otrs/index.pl?Action=AgentTicketZoom;TicketNumber='+activeCellValue+'";"'+activeCellValue+'")' );
  42. }
  43. }
  44. }
Add Comment
Please, Sign In to add comment