Results 1 to 38 of 38

Thread: Print Macro Information Needed

Threaded View

  1. #28

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Location
    Kent, England
    Posts
    713

    Re: Print Macro Information Needed

    so how do I sort these in the array, arrays are one thing that I have never been comfortable understanding? So far this is what I have, hope im not too far of the mark!

    Code:
     
          Dim reg As Variant, oreg As Object, mystr As Variant
    
            Const HKEY_CURRENT_USER = &H80000001
           Set oreg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
           oreg.enumvalues HKEY_CURRENT_USER, "Software\Microsoft\Windows NT\CurrentVersion\Devices", mystr, Arr
           For Each reg In mystr
               oreg.getstringvalue HKEY_CURRENT_USER, "Software\Microsoft\Windows NT\CurrentVersion\Devices", reg, regvalue
               'Debug.Print
               cboSelectPrinterName.AddItem reg '& " on " & Mid(regvalue, InStr(regvalue, ",") + 1)
            Next
                oreg.getstringvalue HKEY_CURRENT_USER, "Software\Microsoft\Windows NT\CurrentVersion\windows", "Device", regvalue
                DefaultPrinter = Left(regvalue, InStr(regvalue, ",") - 1)
                
                    cboSelectPrinterName = DefaultPrinter
                    
    Dim first, last, i, j As Integer
    Dim temp, list As String
    
        first = LBound(mystr)
        last = UBound(mystr)
        For i = first To last - 1
            For j = i + 1 To last
                If mystr(i) > mystr(j) Then
                    temp = mystr(j)
                    mystr(j) = mystr(i)
                    mystr(i) = temp
                End If
            Next j
        Next i
         
        For i = 1 To UBound(mystr)
            list = list & vbCrLf & mystr(i)
        Next
        cboSelectPrinterName.Clear
       
        
       For first = LBound(mystr) To UBound(mystr) - 1
       If list <> "" Then
       cboselecptintername.AddItem mystr(list)
         End If
        
        Next
    Last edited by JayCR; Sep 25th, 2008 at 07:15 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width