Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
|
Lista Forumurilor Pe Tematici
|
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login
POZE MRRRR'S FORUM (VIEW ONLY)
Nu sunteti logat.
|
Nou pe simpatie: angela31 24 ani
| Femeie 24 ani Buzau cauta Barbat 24 - 60 ani |
|
Mrrrr
AdMiN
Inregistrat: acum 17 ani
Postari: 2228
|
|
The code below is saved as .HTA file and will extract bookmark data from Word files existing in the strPath location.
Bookmarks in the Word files are named T2_ian for T2_january, T2_feb for T2_february etc.
While the code could still be optimized, it works fine in this form.
The code has a part of HTML at the beginning, then the required VBS part that does all the magic, then the ending HTML part that creates the GUI.
<head> <title>Gestiunea deseurilor - citire</title>
<HTA:APPLICATION APPLICATIONNAME="Gestiunea deseurilor - citire" SCROLL="no" BORDER="dialog" SINGLEINSTANCE="yes" WINDOWSTATE="normal" ICON="D:\Hazard.ico" > </head>
<script LANGUAGE="VBScript"> Sub Window_onLoad window.resizeTo 330,700
Dim yr yr = Year(Now()) TextBoxYear.value = yr
Dim ds ' #### selecteaza primul deseu automat la deschiderea HTA ds = "150101" DeseuChooser.value = ds End Sub </script>
<script language="VBScript">
Sub CITESTEGestiuneaDeseurilor
Dim strYear Dim strDeseu Dim strValue Dim strPath Dim strDoc Dim objDoc
strYear = TextBoxYear.value If strYear = "" Then MsgBox "Nu ai introdus nici un an" Exit Sub End If
strDeseu = DeseuChooser.value If strDeseu = "" Then MsgBox "Nu ai selectat nici un deseu" Exit Sub End If
Select Case strDeseu
Case 150101 strDoc = "Anexa 1. Fisa nr. 1.0-F.01.04.77-amb.H+C-15.01.01-" & stryear & ".doc"
Case 150102 strDoc = "Anexa 1. Fisa nr. 2.0-F.01.04.77-amb.plastic-15.01.02-" & stryear & ".doc"
Case 070213 strDoc = "Anexa 1. Fisa nr. 3.0-F.01.04.77-des.mat.pl.-07.02.13-" & stryear & ".doc"
Case 160120 strDoc = "Anexa 1. Fisa nr. 4.0-F.01.04.77-sticla-16.01.20-" & stryear & ".doc"
Case 170405 strDoc = "Anexa 1. Fisa nr. 5.0-F.01.04.77-fier vechi-17.04.05-" & stryear & ".doc"
Case 150110 strDoc = "Anexa 1. Fisa nr. 6.1-F.01.04.77-amb.cont.-15.01.10X-" & stryear & ".doc"
Case 160305 strDoc = "Anexa 1. Fisa nr. 6.2-F.01.04.77-des.org.-16.03.05X-" & stryear & ".doc"
Case 160214 strDoc = "Anexa 1. Fisa nr. 7.0-F.01.04.77-DEEE-16.02.14-" & stryear & ".doc"
Case 200301 strDoc = "Anexa 1. Fisa nr. 10.0-F.01.04.77-menajer-20.03.01-" & stryear & ".doc" Case Else
End Select
strPath = "D:\GESTIUNE DESEURI\"& strYear & "\" & strDoc
Set objWord = CreateObject("Word.Application") objWord.Visible = False Set objDoc = objWord.Documents.Open(strPath)
Set objRange = objDoc.Bookmarks("T2_ian").Range strValue = objRange.Text ianValue.value = strValue
Set objRange = objDoc.Bookmarks("T2_feb").Range strValue = objRange.Text febValue.value = strValue
Set objRange = objDoc.Bookmarks("T2_mar").Range strValue = objRange.Text marValue.value = strValue
Set objRange = objDoc.Bookmarks("T2_apr").Range strValue = objRange.Text aprValue.value = strValue
Set objRange = objDoc.Bookmarks("T2_mai").Range strValue = objRange.Text maiValue.value = strValue
Set objRange = objDoc.Bookmarks("T2_iun").Range strValue = objRange.Text iunValue.value = strValue
Set objRange = objDoc.Bookmarks("T2_iul").Range strValue = objRange.Text iulValue.value = strValue Set objRange = objDoc.Bookmarks("T2_aug").Range strValue = objRange.Text augValue.value = strValue
Set objRange = objDoc.Bookmarks("T2_sep").Range strValue = objRange.Text sepValue.value = strValue
Set objRange = objDoc.Bookmarks("T2_oct").Range strValue = objRange.Text octValue.value = strValue
Set objRange = objDoc.Bookmarks("T2_noi").Range strValue = objRange.Text noiValue.value = strValue
Set objRange = objDoc.Bookmarks("T2_dec").Range strValue = objRange.Text decValue.value = strValue
Set objRange = objDoc.Bookmarks("TOTAL").Range strValue = objRange.Text totalValue.value = strValue
objWord.Quit
' #### WARNING: THE FOLLOWING LINES CLOSE ALL INSTANCES OF WORD
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'winword.exe'") For Each objProcess in colProcess objProcess.Terminate() Next
End Sub
' ################ DESCHIDE FISIER ################
Sub Deschide
Dim objDoc Dim objWord Dim strPath Dim strDoc Dim strDeseu Dim strYear
strYear = TextBoxYear.value If strYear = "" Then MsgBox "Nu ai introdus nici un an" Exit Sub End If
strDeseu = DeseuChooser.value
Select Case strDeseu
Case 150101 strDoc = "Anexa 1. Fisa nr. 1.0-F.01.04.77-amb.H+C-15.01.01-" & stryear & ".doc"
Case 150102 strDoc = "Anexa 1. Fisa nr. 2.0-F.01.04.77-amb.plastic-15.01.02-" & stryear & ".doc"
Case 070213 strDoc = "Anexa 1. Fisa nr. 3.0-F.01.04.77-des.mat.pl.-07.02.13-" & stryear & ".doc"
Case 160120 strDoc = "Anexa 1. Fisa nr. 4.0-F.01.04.77-sticla-16.01.20-" & stryear & ".doc"
Case 170405 strDoc = "Anexa 1. Fisa nr. 5.0-F.01.04.77-fier vechi-17.04.05-" & stryear & ".doc"
Case 150110 strDoc = "Anexa 1. Fisa nr. 6.1-F.01.04.77-amb.cont.-15.01.10X-" & stryear & ".doc"
Case 160305 strDoc = "Anexa 1. Fisa nr. 6.2-F.01.04.77-des.org.-16.03.05X-" & stryear & ".doc"
Case 160214 strDoc = "Anexa 1. Fisa nr. 7.0-F.01.04.77-DEEE-16.02.14-" & stryear & ".doc"
Case 200301 strDoc = "Anexa 1. Fisa nr. 10.0-F.01.04.77-menajer-20.03.01-" & stryear & ".doc" Case Else
End Select
strPath = "D:\GESTIUNE DESEURI\"& strYear & "\" & strDoc
Set objWord = CreateObject("Word.Application") objWord.Visible = True Set objDoc = objWord.Documents.Open(strPath)
End Sub </script>
<body>
Anul e: <input type="text" style="background-color: yellow;" name="TextBoxYear" size="4" maxLength="4"> (scrie alt an daca nu e OK)<p>
<font color="red">Selecteaza deseu:</font><br> <select size="9" name="DeseuChooser"> <option value="150101">15.01.01 des. amb. carton</option> <option value="150102">15.01.02 des. amb. plastic</option> <option value="070213">07.02.13 des. mat. plastice</option> <option value="160120">16.01.20 des. sticla</option> <option value="170405">17.04.05 des. fier</option> <option value="150110">15.01.10* amb. contaminat</option> <option value="160305">16.03.05* des. organice</option> <option value="160214">16.02.14 DEEE</option> <option value="200301">20.03.01 des. menajer (13,2 m3)</option> </select><p>
<input type="button" value="Extrage cantitati" name="run_button" onClick="CITESTEGestiuneaDeseurilor" style="background-color: lime;"> <input type="button" value="Deschide fisier" name="run_button" onClick="Deschide" style="background-color: yellow;" > <p>
<font color="red">In camp va aparea cantitatea de deseu / luna:</font><br> <input type="text" style="background-color: lime; height: 20; font-size: 10pt; text-align:center;" name="ianValue" size="15" maxLength="15"> to = ianuarie<br> <input type="text" style="background-color: lime; height: 20; font-size: 10pt; text-align:center;" name="febValue" size="15" maxLength="15"> to = februarie<br> <input type="text" style="background-color: lime; height: 20; font-size: 10pt; text-align:center;" name="marValue" size="15" maxLength="15"> to = martie<br> <input type="text" style="background-color: lime; height: 20; font-size: 10pt; text-align:center;" name="aprValue" size="15" maxLength="15"> to = aprilie<br> <input type="text" style="background-color: lime; height: 20; font-size: 10pt; text-align:center;" name="maiValue" size="15" maxLength="15"> to = mai<br> <input type="text" style="background-color: lime; height: 20; font-size: 10pt; text-align:center;" name="iunValue" size="15" maxLength="15"> to = iunie<br> <input type="text" style="background-color: lime; height: 20; font-size: 10pt; text-align:center;" name="iulValue" size="15" maxLength="15"> to = iulie<br> <input type="text" style="background-color: lime; height: 20; font-size: 10pt; text-align:center;" name="augValue" size="15" maxLength="15"> to = august<br> <input type="text" style="background-color: lime; height: 20; font-size: 10pt; text-align:center;" name="sepValue" size="15" maxLength="15"> to = septembrie<br> <input type="text" style="background-color: lime; height: 20; font-size: 10pt; text-align:center;" name="octValue" size="15" maxLength="15"> to = octombrie<br> <input type="text" style="background-color: lime; height: 20; font-size: 10pt; text-align:center;" name="noiValue" size="15" maxLength="15"> to = noiembrie<br> <input type="text" style="background-color: lime; height: 20; font-size: 10pt; text-align:center;" name="decValue" size="15" maxLength="15"> to = decembrie<p> <input type="text" style="background-color: lime; height: 28; font-size: 14pt; text-align:center;" name="totalValue" size="15" maxLength="15"> to = TOTAL<br>
</body>
|
_______________________________________
|
|
pus acum 3 ani |
|