Menampilkan Kotak Dialog Printer, setelah dipilih akan ditampilkan di Range A1
Sub cetak()
Application.Dialogs(xlDialogPrinterSetup).Show
If Application.DisplayAlerts = False Then
Exit Sub
Else
Range("A1").Value = Application.ActivePrinter
End If
End Sub
Langsung Memilih Printer berdasarkan namanya
Sub pilihPrint()
Application.ActivePrinter = "CutePDF Writer on CPW2:"
End Sub
Option Explicit Sub IPtest() Dim wsh As Object Dim RegEx As Object, RegM As Object Dim FSO As Object, fil As Object Dim ts As Object, txtAll As String, TempFil As String Set wsh = CreateObject("WScript.Shell") Set FSO = CreateObject("Scripting.FileSystemObject") Set RegEx = CreateObject("vbscript.regexp") TempFil = "C:\myip.txt" ' Save ipconfig info to temporary file wsh.Run "%comspec% /c ipconfig > " & TempFil, 0, True With RegEx .Pattern = "(\d{1,3}\.){3}\d{1,3}" .Global = False End With Set fil = FSO.GetFile(TempFil) ' Access temporary file Set ts = fil.OpenAsTextStream(1) txtAll = ts.ReadAll Set RegM = RegEx.Execute(txtAll) ' Return IP address to Activesheet cell A1 by parsing text ActiveSheet.Range("A1").Value = RegM(0) ActiveSheet.Range("A1").EntireColumn.AutoFit ts.Close ' Remove temp file Kill TempFil Set ts = Nothing Set wsh = Nothing Set fil = Nothing Set FSO = Nothing Set RegM = Nothing Set RegEx = Nothing End Sub
Function maxIfs(maxRange As Range, criteriaRange As Range, criterion As Variant) As Variant
maxIfs = Empty
For i = 1 To maxRange.Cells.Count
If criteriaRange.Cells(i).Value = criterion Then
If maxIfs = Empty Then
maxIfs = maxRange.Cells(i).Value
Else
maxIfs = Application.WorksheetFunction.Max(maxIfs, maxRange.Cells(i).Value)
End If
End If
Next
End Function
maxIfs = Empty
For i = 1 To maxRange.Cells.Count
If criteriaRange.Cells(i).Value = criterion Then
If maxIfs = Empty Then
maxIfs = maxRange.Cells(i).Value
Else
maxIfs = Application.WorksheetFunction.Max(maxIfs, maxRange.Cells(i).Value)
End If
End If
Next
End Function
Langganan:
Postingan (Atom)