Main > Forum > 1C:Enterprise Platform > Studying 1C:Enterprise platform > Use Print Page Layout Form and Saved Features

Forum

Search UsersRules
Use Print Page Layout Form and Saved Features
#1
Active user
Points:: 0
Joined:: Mar 29, 2016

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?

Profile
#2
Guest
Points::
Joined::

Hello,

I'm afraid you will have to use COMObject for that. Try the following script, hope this helps:

Code
    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"));

Profile
#3
Active user
Points:: 0
Joined:: Mar 29, 2016

Thanks Timofey. Your writen code very helpful.

I write this code.

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

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.