Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function FormUpdateLoad() {
- if (Document.getDocumentState == 0 ) {
- var docid;
- var clientPath;
- var ExcelFilePath;
- var oDoc;
- var docidlength;
- var docidsub;
- // document.cell("VER.D1").value = "";
- // initialize ActiveXObject and create an object of Scripting.FileSystemObject.
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- // if condition to check whether the specified file exists or not.
- clientPath = document.interpret("CLNTDIR()");
- // ExcelFilePath = clientPath + "GeneralTemplateFormVersionRpt.xls";
- ExcelFilePath = clientPath + "FormVersionReport.xls";
- if(fso.FileExists(ExcelFilePath))
- {
- docid = document.interpret("DOCID()");
- docidlength = (String(docid).length) - 1;
- // Document.MessageBox ("Message", docid, 0);
- docidsub = String(docid).substring(0, docidlength);
- var oExcel = new ActiveXObject("Excel.Application");
- //disable on open macro from firing
- oExcel.EnableEvents = false;
- var oWorkBook = oExcel.Workbooks.Open(ExcelFilePath);
- oWorkBook.Sheets("Document Manager").Select;
- oExcel.DisplayAlerts = false;
- //show the excel spreadsheet to the user
- oExcel.Visible=false;
- var endofdm = false;
- var counter = 6;
- var dmindex = 1;
- while(oExcel.Cells(counter, 2).Value != null){
- // Document.MessageBox ("Message", counter, 0);
- oExcel.Range("G"+counter).Select;
- // Document.MessageBox ("Message", String(oExcel.ActiveCell.Value).substring(0, docidlength), 0);
- // Document.MessageBox ("Message", docidsub, 0);
- if (String(oExcel.ActiveCell.Value).substring(0,docidlength) == docidsub) {
- oExcel.Range("F"+counter).Select;
- // document.cell("VER.D1").value = oExcel.ActiveCell.Value;
- document.cell("UVR").value = oExcel.ActiveCell.Value;
- document.cell("VER.D1").value = document.cell("UVR").value;
- // Document.MessageBox ("Message", oExcel.ActiveCell.Value, 0);
- oExcel.Range("I"+counter).Select;
- document.cell("VER.F1").value = oExcel.ActiveCell.Value;
- document.recalculate(0);
- break;
- }
- counter++;
- dmindex++;
- }
- oExcel.Workbooks.close();
- if (document.cell("VER.B1").value != document.cell("VER.D1").value) {
- document.cell("VER.E1").value = "Out of Date";
- } else {
- document.cell("VER.E1").value = "";
- }
- }
- else
- {
- //Document.MessageBox ("Message", "Hi", 0);
- document.cell("VER.D1").value = "";
- document.cell("VER.E1").value = "";
- }
- document.recalculate(0);
- }
- fso = null;
- document.recalculate(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement