Use Print Page Layout Form and Saved Features

Understanding basics of 1C:Enterprise platform. To start working with 1C:Enterprise platform visit Getting started page

#1
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Mar 29, 2016
Company: DND YAZILIM LTD.

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?

Download 1.png (155.24 KB)
Edited: Hüseyin Çağrı Bayraktar - Mar 03, 2017 05:51 AM
 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

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

 
#3
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Mar 29, 2016
Company: DND YAZILIM LTD.

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

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

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.