oxb

Member
  • Content count

    29
  • Joined

  • Last visited

Community Reputation

0 Neutral

About oxb

  1. Hi Gunsmokingman After implementing youre code to the server and using it for a while, i am pleased to say that its working perfectly Just wanted to say thanx again for youre help, me and my colleagues are loving it! I hope i can call on you if i ever need help again.
  2. Anyway gotta go sleep now early rise tomorrow. Thanx for the input!
  3. i know and its very nice but read above it trows an error cant wait to finish?
  4. Showoff Very nice, i got whipped by the master GZonna test now Good skills Thanx Gives an error Cant wait for process to finish line 169??
  5. Got the script to run without any userinput at all. It now finds the ?????.doc copies it to the found name _factuur.doc There wil only be one file in each dir using _offerte.doc so it will never take the wrong file. deletes itself and presto! Automation rocks! I like this stuff but it takes good practice and a lot of google and help from my new found friend Gunsmokingman V\currentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName))) Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Obj For Each Obj In Fso.GetFolder(".").Files If LCase(Right(Obj.Name,12)) = "_offerte.doc" Then sText = Obj.name sText = Left(sText, Len(sText) - 12) Set FSO = CreateObject("Scripting.FileSystemObject") fso.copyfile Obj.name , sText & "_factuur.doc" End If Next Const wdReplaceAll = 2 Set oWord = CreateObject("Word.Application") oWord.Visible = True set oDoc = oWord.Documents.Open (currentdirectory & sText & "_factuur.doc") With oWord.Selection .Find.Text = "Offerte:" .Find.Replacement.Text = "factuur:" .Find.Forward = True .Find.MatchWholeWord = True .Find.Execute ,,,,,,,,,,wdReplaceAll .Find.Text = "Na eventuele accordatie stellen wij betaling per pin op prijs." .Find.Replacement.Text = "Wij danken u voor uw opdracht, graag betaling via PIN" .Find.Forward = True .Find.MatchWholeWord = True .Find.Execute ,,,,,,,,,,wdReplaceAll End With oDoc.Save Set objFSO = CreateObject("Scripting.FileSystemObject") strScript = Wscript.ScriptFullName objFSO.DeleteFile(strScript) PS i edited the Hta accordingly (If Fso.driveExists (myCur)).
  6. I came up with this input = Inputbox("Geef naam, bijv: De Groot >Zonder _offerte.doc!") if IsNull(strValue) then strValue = 0 Else strValue = (strValue) end If if strvalue <> 1 then But your`s is better because it echo`s bear in mind that i`m taking babysteps Also i edited the .hta file so that the dir it runs from it sets the driveletter and dir to use. It runs ok, but do you see a problem with it? Set objShell = CreateObject("WScript.Shell") myCur = objShell.CurrentDirectory If Fso.driveExists (myCur) Then <NOT SURE ABOUT THIS LINE BEEING CORRECT '-> Make First Folder Then Copy offerte.doc Dim P = (myCur & "\2013\") & LCase(In1.value)
  7. I tried that and nothing happens? So no probs there. Greetz
  8. Hmmkay I think i`ll better stick to my first script where the user inputs the name of the file to be altered. This way i get my userinput_offerte.doc and userinput_factuur.doc Further all is working perfect im very glad you helped me get there. Just wanted to take away the user input. Thanks again. Using this script now currentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName))) input = Inputbox("Geef naam, bijv: De Groot >Zonder _offerte.doc!") dim fso Set FSO = CreateObject("Scripting.FileSystemObject") Fso.Copyfile input & "_offerte.doc" , input & "_factuur.doc" Const wdReplaceAll = 2 Set oWord = CreateObject("Word.Application") oWord.Visible = False set oDoc = oWord.Documents.Open (currentdirectory & input & "_factuur.doc") With oWord.Selection .Find.Text = "Offerte:" .Find.Replacement.Text = "factuur:" .Find.Forward = True .Find.MatchWholeWord = True .Find.Execute ,,,,,,,,,,wdReplaceAll .Find.Text = "Na eventuele accordatie stellen wij betaling per pin op prijs." .Find.Replacement.Text = "Wij danken u voor uw opdracht, graag betaling via PIN" .Find.Forward = True .Find.MatchWholeWord = True .Find.Execute ,,,,,,,,,,wdReplaceAll End With oDoc.Save oDoc.Close set oDoc = oWord.Documents.Open (currentdirectory & input & "_factuur.doc") oWord.Visible = true Set objFSO = CreateObject("Scripting.FileSystemObject") strScript = Wscript.ScriptFullName objFSO.DeleteFile(strScript)
  9. No because it is an option to run, and it will only need to run after the offerte.doc is filled in. There is a chance it will never be run if the order is cancelled. Have you got any ideas how to edit the vbs so that the file is copied to name_factuur? Greetz oscar
  10. Ok So far so good The file is found the script does its magic. Now im left with another question i need the file to be copied and saved as a new document but i need part of the name replaced. What i am left with now is name_offerte.doc is copied over to name_offerte.docfactuur.doc<in one line Is there a way to take the last part of the string in name_offerte.doc where i only get the name as a string minus _offerte.doc? I read you can use replace function but i cant see to implement that The tricky thing is the file needs to be opened at the end so if i rename it how do i open it if i dont know its name if the name is not always the same.(only the end part _offerte.doc, or _factuur.doc) dont know if i make any sense but what i need is the file to be opened word replace takes place and file needs to be saved as name_factuur.doc CD = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName))) Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Obj For Each Obj In Fso.GetFolder(".").Files If LCase(Right(Obj.Name,3)) = "doc" Then Set FSO = CreateObject("Scripting.FileSystemObject") Fso.Copyfile Obj.name , Obj.name & "" & "Factuur.doc" Set oWord = CreateObject("Word.Application") oWord.Visible = True set oDoc = oWord.Documents.Open (CD & Obj.name & "factuur.doc") With oWord.Selection .Find.Text = "Offerte:" .Find.Replacement.Text = "factuur:" .Find.Forward = True .Find.MatchWholeWord = True .Find.Execute ,,,,,,,,,,wdReplaceAll .Find.Text = "Na eventuele accordatie stellen wij betaling per pin op prijs." .Find.Replacement.Text = "Wij danken u voor uw opdracht, graag betaling via PIN" .Find.Forward = True .Find.MatchWholeWord = True .Find.Execute ,,,,,,,,,,wdReplaceAll End With oDoc.Save oDoc.Close set oDoc = oWord.Documents.Open (CD & Obj.name & "factuur.doc") oWord.Visible = true Set objFSO = CreateObject("Scripting.FileSystemObject") strScript = Wscript.ScriptFullName objFSO.DeleteFile(strScript) End if Next
  11. Still one more question How can i make this script look for the .doc file and automaticly use that .doc? This vbs wil be in the same folder as the userinput,doc The userinput.doc name will change every time so i would like to use a wildcard like in dos *.doc but dont know how to do it in vbs. Note that there wil be only one .doc file in the same directory as this vbs script. it wil always be named like this userinput_offerte.doc. I wouldt like to take out the userinput just click and go. currentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName))) input = Inputbox("Geef naam, bijv: De Groot") dim fso Set FSO = CreateObject("Scripting.FileSystemObject") Fso.Copyfile input & "_offerte.doc" , input & "_factuur.doc" Const wdReplaceAll = 2 Set oWord = CreateObject("Word.Application") oWord.Visible =True set oDoc = oWord.Documents.Open (currentdirectory & input & "_factuur.doc") With oWord.Selection .Find.Text = "Offerte:" .Find.Replacement.Text = "factuur:" .Find.Forward = True .Find.MatchWholeWord = True .Find.Execute ,,,,,,,,,,wdReplaceAll .Find.Text = "Na eventuele accordatie stellen wij betaling per pin op prijs." .Find.Replacement.Text = "Wij danken u voor uw opdracht, graag betaling via PIN" .Find.Forward = True .Find.MatchWholeWord = True .Find.Execute ,,,,,,,,,,wdReplaceAll End With oDoc.Save Set objFSO = CreateObject("Scripting.FileSystemObject") strScript = Wscript.ScriptFullName objFSO.DeleteFile(strScript)
  12. Damnit Got a problem Today i tried to run the script on the NAS but i believe the path is not correct. On the pc there is a network connection to the drive (Z:) In the script i tried to put in the networkdriveletter Z: The script runs and gives error not finding document, the folder is not created and there are no files copied. Do i have to fill in something like %networkdrive% or %networkpath% in line 137/139 So dissapointed here at home everything worked fine even got the script to take user input to fill in the adress in the document. I Any ideas? Thanx EDIT Nevermind got it fixed stupid was running the hta locally not from nas drive
  13. That is the initial steep of the curve, after you will get the hang of it you will probably start wondering how come that some (not necessarily all ) programmers have this quirk for selling you trifling things as if they were the only geniuses on earth capable of doing that . Seriously, I have seen guys putting together half @§§ed MS Access "custom databases" (actually no more that a few forms and reports) talking as if they were Linus Torvalds or Sergey Brin jaclaz LoL Yeah i know what you mean, i am quite good as to setting up a network enviroment as a hobby. Sometimes i have some it guy come over and i have to make corrections to his s***. My brother in law wanted a vpn connection to his office, the reply was: not possible! you need new computers i spend some time on it and got it to work. Just tried to rip him off I
  14. Thanks for all the effort, And thanks for the good job statement that means a lot coming from you. Thanks to the others for the input i got a little wizer in scripting. The thing is sometimes i want something automated and then i go all-in. But it takes a long time before i have a new project, and by then i forgot most part of it. If you see the amount of code used to do something this simple you get some more respect for coders and programmers. We are all accustomed that the pc works when we turn it on, but really never stand stil by whats behind it all. So respect to all of you Maybe we meet again on this forum if i got something else to play around with.