Sorry, I did not copy the coding across correctly, I meant to delete the = 0 part of the coding. Yes, you are quite right that I should have the if endif scenario. But that does not affect the outcome here. Whether the if is used or not, the setdefaultprinter only works if I put in the correct case of the name of the server. But thanks for pointing that out Les
Oh Allen, the irony - yes you had the gold in your hands. I hate it when that happens to me, when its been in front of my eyes all along and I missed it. Been there many times.
To ShaneEp, your suggestion would only work if all the servers names were in lower case, which they may not be. The more relevant question is why the case sensitivity is an issue for setdefaultprinter when its not an issue for the vbs coding. The vbs coding does not care about the case sensitivity.
To Lonkero, the issue may only affect this specific program, in which case its not a major issue. But I can put in Server (CAPS) in the vbs code and it works. It only fails with setdefaultprinter macro. I have just checked the coding and at this specific client the addprinter is set using server not Server. So you may have something there, but your explanation does not explain why the VBS code does not care about the case sensitivity. I brought the CD of the program home with me. I will test out whether the setdefaultprinter function working properly depends on the case of the server name or on the case of the addprinter function and get back to you. But this below works
Set net = WScript.CreateObject("wscript.network") net.SetDefaultPrinter "\\Server\ict colour"
I have no answer for why the capital S works in the vbs script, but it doesn't work in setdefaultprinter.
Worst thing about coding has always been the damn punctuation lol ! Gets me every time.
|