Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. function FormUpdateLoad() {
  2. if (Document.getDocumentState == 0 ) {
  3. var docid;
  4. var clientPath;
  5. var ExcelFilePath;
  6. var oDoc;
  7. var docidlength;
  8. var docidsub;
  9. // document.cell("VER.D1").value = "";
  10. // initialize ActiveXObject and create an object of Scripting.FileSystemObject.
  11. var fso = new ActiveXObject("Scripting.FileSystemObject");
  12. // if condition to check whether the specified file exists or not.
  13. clientPath = document.interpret("CLNTDIR()");
  14.  
  15.  
  16. // ExcelFilePath = clientPath + "GeneralTemplateFormVersionRpt.xls";
  17. ExcelFilePath = clientPath + "FormVersionReport.xls";
  18.  
  19. if(fso.FileExists(ExcelFilePath))
  20. {
  21. docid = document.interpret("DOCID()");
  22. docidlength = (String(docid).length) - 1;
  23.  
  24. // Document.MessageBox ("Message", docid, 0);
  25.  
  26.  
  27. docidsub = String(docid).substring(0, docidlength);
  28.  
  29.  
  30.  
  31. var oExcel = new ActiveXObject("Excel.Application");
  32.  
  33. //disable on open macro from firing
  34. oExcel.EnableEvents = false;
  35.  
  36. var oWorkBook = oExcel.Workbooks.Open(ExcelFilePath);
  37.  
  38.  
  39. oWorkBook.Sheets("Document Manager").Select;
  40.  
  41. oExcel.DisplayAlerts = false;
  42. //show the excel spreadsheet to the user
  43. oExcel.Visible=false;
  44.  
  45.  
  46.  
  47.  
  48. var endofdm = false;
  49.  
  50. var counter = 6;
  51. var dmindex = 1;
  52.  
  53.  
  54. while(oExcel.Cells(counter, 2).Value != null){
  55.  
  56. // Document.MessageBox ("Message", counter, 0);
  57. oExcel.Range("G"+counter).Select;
  58.  
  59. // Document.MessageBox ("Message", String(oExcel.ActiveCell.Value).substring(0, docidlength), 0);
  60. // Document.MessageBox ("Message", docidsub, 0);
  61. if (String(oExcel.ActiveCell.Value).substring(0,docidlength) == docidsub) {
  62. oExcel.Range("F"+counter).Select;
  63. // document.cell("VER.D1").value = oExcel.ActiveCell.Value;
  64. document.cell("UVR").value = oExcel.ActiveCell.Value;
  65. document.cell("VER.D1").value = document.cell("UVR").value;
  66. // Document.MessageBox ("Message", oExcel.ActiveCell.Value, 0);
  67. oExcel.Range("I"+counter).Select;
  68. document.cell("VER.F1").value = oExcel.ActiveCell.Value;
  69. document.recalculate(0);
  70. break;
  71. }
  72. counter++;
  73. dmindex++;
  74.  
  75. }
  76.  
  77.  
  78. oExcel.Workbooks.close();
  79.  
  80.  
  81. if (document.cell("VER.B1").value != document.cell("VER.D1").value) {
  82. document.cell("VER.E1").value = "Out of Date";
  83.  
  84. } else {
  85. document.cell("VER.E1").value = "";
  86.  
  87. }
  88. }
  89. else
  90. {
  91. //Document.MessageBox ("Message", "Hi", 0);
  92. document.cell("VER.D1").value = "";
  93. document.cell("VER.E1").value = "";
  94. }
  95. document.recalculate(0);
  96. }
  97. fso = null;
  98. document.recalculate(0);
  99.  
  100.  
  101.  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement