Understanding basics of 1C:Enterprise platform. To start working with 1C:Enterprise platform visit Getting started page
I want to save Page layout features for a my designed template. I can get all printers. But i can't get selected printer paper size. How i do this like picture?
Hello, I'm afraid you will have to use COMObject for that. Try the following script, hope this helps:
Script = Новый ComObject("MSScriptControl.ScriptControl"); Script.Language = "vbscript"; Script.AddCode(" |Function GetDefaultPrinter() |GetDefaultPrinter=vbNullString |Set objWMIService=GetObject(""winmgmts:"" _ |& ""{impersonationLevel=impersonate}!\\.\root\cimv2"") |Set colInstalledPrinters=objWMIService.ExecQuery _ |(""Select * from Win32_Printer"") |For Each objPrinter in colInstalledPrinters |If objPrinter.Attributes and 4 Then |GetDefaultPrinter=objPrinter.Name |Exit For |End If |Next |End Function"); DefaultPrinter = TrimAll(Script.run("GetDefaultPrinter"));
Thanks Timofey. Your writen code very helpful.I write this code.
&AtServer Function GetPapersOfPrinter() ScriptGPP = New ComObject("MSScriptControl.ScriptControl"); ScriptGPP.Language = "vbscript"; pStrPaper = " |Function GetPrinterPaper() |Set objWMIService = GetObject(""winmgmts:"" _ |& ""{impersonationLevel=impersonate}!\\.\root\cimv2"") |GetPrinterPaper=VbNullString | Set colInstalledPages = objWMIService.ExecQuery _ | (""SELECT * FROM Win32_Printer Where DeviceID='" + StrReplace(ThisForm.Yazıcı,"'","""\""") + "'"") | For Each objPage In colInstalledPages | For Each objPageName In objPage.PrinterPaperNames | GetPrinterPaper = GetPrinterPaper & "";-;"" & objPageName | Next | Next |End Function"; ScriptGPP.AddCode(pStrPaper); GetPrinterPapers = TrimAll(ScriptGPP.run("GetPrinterPaper")); PrinterPapersArr = StrSplit(GetPrinterPapers,";-;",False); Vlp = New ValueList; Vlp.LoadValues(PrinterPapersArr); If Vlp.Count() = 0 Then Vlp.Add("A4"); EndIf; Return Vlp; EndFunction &AtServer Function GetPrinters() ScriptGP = New ComObject("MSScriptControl.ScriptControl"); ScriptGP.Language = "vbscript"; ScriptGP.AddCode(" |Function GetPrinter() |Set objWMIService = GetObject(""winmgmts:"" _ |& ""{impersonationLevel=impersonate}!\\.\root\cimv2"") |Set colInstalledPrinters = objWMIService.ExecQuery _ | (""Select * from Win32_PrinterConfiguration"") |GetPrinter=VbNullString |For Each objPrinter in colInstalledPrinters | GetPrinter=GetPrinter & objPrinter.Name | GetPrinter=GetPrinter & "";--;"" |Next |End Function"); GetPrinter = TrimAll(ScriptGP.run("GetPrinter")); PrintersArr = StrSplit(GetPrinter,";--;",False); Vl = New ValueList; Vl.LoadValues(PrintersArr); Return Vl; EndFunction
A confirmation e-mail has been sent to the e-mail address you provided .
Click the link in the e-mail to confirm and activate the subscription.
Get our brochures now! They are packed with all the info you need on 1C:Enterprise, a comprehensive technological platform with a wide range of built-in and separate tools and services and a system of off-the-shelf solutions powered by this platform. Plus, data on customer projects, including stats on their size and the effect of automation. Just leave your email address to download!
We're committed to your privacy. 1С uses the information you provide to us to contact you about our relevant content, products, and services. You may unsubscribe from these communications at any time. For more information, check out our Privacy Policy
Your request has been successfully sent.