Results 1 to 40 of 40

Thread: [RESOLVED] Printer Document Name

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    Resolved [RESOLVED] Printer Document Name

    When I use API, I can do this:
    VB Code:
    1. Private Type DOCINFO
    2.     cbSize As Long
    3.     lpszDocName As String
    4.     lpszOutput As String
    5.     lpszDatatype As String
    6.     fwType As Long
    7. End Type
    8.  
    9. Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
    10. Private Declare Function StartDoc Lib "gdi32" Alias "StartDocA" (ByVal hdc As Long, lpdi As DOCINFO) As Long
    11. Private Declare Function EndDoc Lib "gdi32" (ByVal hdc As Long) As Long
    12. Private Declare Function StartPage Lib "gdi32" (ByVal hdc As Long) As Long
    13. Private Declare Function EndPage Lib "gdi32" (ByVal hdc As Long) As Long
    14.  
    15. Private Function PrintTest(ByVal hPrintDc As Long)
    16.     Dim Result As Long
    17.     Dim di As DOCINFO  'Structure for Print Document info
    18.    
    19.     di.cbSize = 20   ' Size of DOCINFO structure
    20.     di.lpszDocName = "Document Name: 1234567..."
    21.     Result = StartDoc(hPrintDc, di) ' Start a new print document
    22.  
    23.     '...... the rest of the code...
    24. End Function
    It will print on the printer with a document name, but when I don't use API, how can I set the document name ?

    For example:
    VB Code:
    1. Private Function PrintTest()
    2.     [COLOR=Red][B]Printer.DocumentName = "Document Name: 1234567..."[/B][/COLOR]
    3.     Printer.Print "testing..."
    4.     Printer.EndDoc
    5. End Function
    The printer does not have a DocumentName property, so I cannot do that, but how else ?

    Can I mix the 2, and set the document name using api, but print on the printer object ?
    Last edited by CVMichael; Dec 15th, 2006 at 04:38 PM.

  2. #2

  3. #3
    Hyperactive Member BrendanDavis's Avatar
    Join Date
    Oct 2006
    Location
    Florida
    Posts
    492

    Re: Printer Document Name

    Quote Originally Posted by MartinLiss
    Why not just use the API?
    Smaller, less bloated code? Beats me...

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    Re: Printer Document Name

    Quote Originally Posted by MartinLiss
    Why not just use the API?
    Because all the code (like 500 lines at least) is written for the Printer object, all the drawing and the text, etc... If I have to change everything to API, it will be way too much to change...

    All I need to do, is to be able to give it a name...

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: Printer Document Name

    Well this works.

    VB Code:
    1. Private Function PrintTest(ByVal hPrintDc As Long)
    2.     Dim Result As Long
    3.     Dim di As DOCINFO  'Structure for Print Document info
    4.    
    5.     di.cbSize = 20   ' Size of DOCINFO structure
    6.     di.lpszDocName = "Document Name: 1234567..."
    7.     [HL="#FFFF80"]Printer.Print di.lpszDocName[/HL]
    8.     Result = StartDoc(hPrintDc, di) ' Start a new print document
    9.     Result = EndDoc(hPrintDc)
    10.     '...... the rest of the code...
    11. End Function

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    Re: Printer Document Name

    Quote Originally Posted by MartinLiss
    Well this works.

    VB Code:
    1. Private Function PrintTest(ByVal hPrintDc As Long)
    2.     Dim Result As Long
    3.     Dim di As DOCINFO  'Structure for Print Document info
    4.    
    5.     di.cbSize = 20   ' Size of DOCINFO structure
    6.     di.lpszDocName = "Document Name: 1234567..."
    7.     [HL="#FFFF80"]Printer.Print di.lpszDocName[/HL]
    8.     Result = StartDoc(hPrintDc, di) ' Start a new print document
    9.     Result = EndDoc(hPrintDc)
    10.     '...... the rest of the code...
    11. End Function
    I did not test it, but i'm sure that that will just print the document name on the paper....
    I need to set the document name, the document that goes to the printer.
    Not what it's on paper, but the paper's name....

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: Printer Document Name

    Quote Originally Posted by CVMichael
    I did not test it, but i'm sure that that will just print the document name on the paper....
    I need to set the document name, the document that goes to the printer.
    Not what it's on paper, but the paper's name....
    Yes, that's all it does.

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    Re: Printer Document Name

    Maybe I should explain this a little more for what I need it like this:

    2 reasons:

    First: You know those really big printers that are photocopier, scanner, etc, like this one:

    We have one of those at work, and the printer has a log. When I print from my program without using API, the document name in the log it just shows the application name, but I need it to show whatever i'm actually printing...

    Second reason: I'm printing to a PDF Creator (a program that takes the print-out, and converts it to PDF), the name of the PDF file name is taken from the Document Name, so if I print many things, it will have the same name (with a time stamp in the file name also), but that's not good enough because if I print in a very short period of time (a few seconds), then I won't be able to tell what file is for what document.
    I know that a way to solve this is to print then wait until the file is created, rename it, then print again, wait... and so on, but that takes a lot of time when printing many documents.

    If I have to convert to API, well, lets just say that it took me like 3 days to get it to work with the printer object (the printout is very complex), converting to API will take me too long...

    I just need a simple thing... to set the document name

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Printer Document Name

    i have found some sample code from microsoft that maybe can do what you want
    VB Code:
    1. Private Sub Command1_Click()
    2.    ' Combine API Calls with the Printer object
    3.       Dim OutString As String
    4.       Dim lf As LOGFONT
    5.       Dim result As Long
    6.       Dim hOldfont As Long
    7.       Dim hPrintDc As Long
    8.       Dim hFont As Long
    9.  
    10.       Printer.Print "Printer Object"
    11.       hPrintDc = Printer.hdc
    12.       OutString = "Hello World"
    13.  
    14.       lf.lfEscapement = 1800
    15.       lf.lfHeight = (DESIREDFONTSIZE * -20) / Printer.TwipsPerPixelY
    16.       hFont = CreateFontIndirect(lf)
    17.       hOldfont = SelectObject(hPrintDc, hFont)
    18.       result = TextOut(hPrintDc, 1000, 1000, OutString, Len(OutString))
    19.       result = SelectObject(hPrintDc, hOldfont)
    20.       result = DeleteObject(hFont)
    21.  
    22.       Printer.Print "xyz"
    23.       Printer.EndDoc
    24.    End Sub
    This will print a single page to the current default printer with "Printer Object" and "xyz" printed normally and "Hello World" printed rotated 180 degrees.
    if you want the rest of the article http://support.microsoft.com/kb/175535 but the above is all that is relevant
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  10. #10

  11. #11
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Printer Document Name

    i realised that this is not what he actually wants to do, but the above is a method of combining the printer object and API calls, which is what he wants to do
    He wants to grab and print the print document name
    not print the name, set the name going to the printer manager
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    Re: Printer Document Name

    Bump...

    Still did not find a solution for this

  13. #13

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    Re: Printer Document Name

    Quote Originally Posted by MartinLiss
    Please don't bump your threads.
    It's been 2 days since last post on this thread, it's not like I bumped after a few hours, and this is the first time I bumped on this thread...

    I think it's fair to let everyone know that i'm still looking for an anser to this

  15. #15
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: Printer Document Name

    What is "fair" is to give everyone the same chance at getting their question answered. If we were all to compete for the top spot or even for the first page it would be a real mess.

  16. #16
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Printer Document Name

    Send a PM to Merri - he apparently has a large library of printer tools he has created.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  17. #17

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    Re: Printer Document Name

    Finally !!!

    After 4 days of searching, this is the thread that helped me:
    http://www.vbforums.com/showthread.php?t=258243

  18. #18
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: [RESOLVED] Printer Document Name

    CVMichael,

    Could you possibly post a small project that shows how to do this. Or point me in the direction. This questions been around for a while. Glad it seems to have just been solved.

    I don't know what an API is, don't know if how to use a class module, don't know how to use the dll (and the link doesn't work), and I can't even find where the code :

    Dim prJob as New ApiPrintJob
    prJob.DocumentName = "A catchy name"

    is located in Merrions web site. Which seems to be the guts of it.

  19. #19

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    Re: [RESOLVED] Printer Document Name

    First go into the PDFCreator Options, and make sure in the Auto-Save you have PDF, set a file name format, then set the directory to save into.


    When you print in VB, just set the default printer to PDFCreator, and print to it...
    Something like this:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Dim P As Printer
    5.    
    6.     For Each P In Printers
    7.         If P.DeviceName = "PDFCreator" Then
    8.             Set Printer = P
    9.             Exit For
    10.         End If
    11.     Next P
    12.    
    13.     Printer.FontSize = 50
    14.     Printer.Print "Hello world !!"
    15.     Printer.EndDoc
    16. End Sub
    That will create a file in the directory you specified in the options, named something like "Microsoft Visual Basic, 20061222090914.pdf"

    Now if you want to name it diferently, other than "Microsoft Visual Basic", things get a little more complicated.

    First search for EventVB_I.dll in the UtilityBank (here), download it (compile the project if neccesary), and put the DLL in C:\Windows\System32

    In your project go to reference, and add the DLL in the list, it should look like this:


    After that, you just have to use the code that Merrion posted in post #7
    So, the end result is:
    VB Code:
    1. Option Explicit
    2.  
    3. Dim WithEvents vbLink As APIFunctions
    4.  
    5. Private Sub Form_Load()
    6.     Dim P As Printer
    7.     Set vbLink = New APIFunctions
    8.    
    9.     For Each P In Printers
    10.         If P.DeviceName = "PDFCreator" Then
    11.             Set Printer = P
    12.             Exit For
    13.         End If
    14.     Next P
    15.    
    16.     Printer.FontSize = 50
    17.     Printer.Print "Hello world !!"
    18.     RenameJob "Microsoft Visual Basic", "Testing save to PDF file"
    19.     DoEvents
    20.     Printer.EndDoc
    21. End Sub
    22.  
    23. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    24.     Set vbLink = Nothing
    25. End Sub
    26.  
    27. Public Sub RenameJob(ByVal OldName As String, ByVal NewName As String)
    28.     Dim vbPrinter As ApiPrinter
    29.     Dim vbJob As ApiPrintJob
    30.    
    31.     Set vbPrinter = New ApiPrinter
    32.     vbPrinter.DeviceName = Printer.DeviceName
    33.    
    34.     For Each vbJob In vbPrinter.PrintJobs
    35.         If vbJob.DocumentName = OldName Then
    36.             vbJob.DocumentName = NewName
    37.             Exit For
    38.         End If
    39.     Next vbJob
    40. End Sub
    Attached Images Attached Images   
    Last edited by CVMichael; Dec 22nd, 2006 at 12:15 PM.

  20. #20
    Junior Member
    Join Date
    Nov 2006
    Posts
    23

    Re: [RESOLVED] Printer Document Name

    I have a problem with the PDFCreator. The function Merrion made works fine, i have a breakpoint just before the Printer.EndDoc and i can see that the document name has changed, but when the PDFCreator window appears, it still have the "Microsoft Visual Basic" name. What could be the problem? Its a problem with VB code or with the PDFCreator?

    Last edited by Zerodyme; Jan 5th, 2007 at 06:22 AM.

  21. #21
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [RESOLVED] Printer Document Name

    i think pdf creator is called as soon as the first page is completed, so the document name would be taken from that point
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  22. #22

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    Re: [RESOLVED] Printer Document Name

    Don't change the name just before the Printer.EndDoc, change it as soon as you start to write on the printer, you can even do something like this:

    Pseudocode:
    VB Code:
    1. ' Select the printer
    2.  
    3. Printer.Print ""    '  first call initializes the printer
    4. DoEvents ' I don't think DoEvents is really neccessary, but just in case...
    5. RenameJob "Microsoft Visual Basic", "Testing save to PDF file" ' Rename document
    6.  
    7. Printer.CurrentY = 0
    8. Printer.CurrentX = 0
    9. Printer.Print "Hello world !"  ' print whaterver you wanted to print...
    10.  
    11. Printer.EndDoc

  23. #23
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: [RESOLVED] Printer Document Name

    Zerodyme, Did you ever solve your problem?
    I want the save as file dialog box to show up to allow an alternative path and filename.
    I've found that there's a bit of a Catch 22. Hope someone can give me a clue on how to get around it.

    This dialogbox is initiated at the first thing that is sent to the printer eg Printer.Print "Hello world !". This first line also sets up the first vbPrinter.PrintJobs. Without a vbPrinter.PrintJobs value defined the RenameJob routine doesn't work as it skips the rename.

    VB Code:
    1. For Each vbJob In vbPrinter.PrintJobs
    2.         If vbJob.DocumentName = OldName Then
    3.             vbJob.DocumentName = NewName
    4.             Exit For
    5.         End If
    6.     Next vbJob
    So, I can't rename the job before the saveas dialog appears as RenameJob must be placed after the printer is initialised.

    Anyone have any ideas? Desperately need help.
    Last edited by sgrya1; Jan 7th, 2007 at 08:46 PM.

  24. #24
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: [RESOLVED] Printer Document Name

    I don't surpose anyone has an idea on where the string variable containing "Microsoft Visual Basic" (or the program executable title) is stored? If this were able to be changed then...

  25. #25
    Junior Member
    Join Date
    Nov 2006
    Posts
    23

    Re: [RESOLVED] Printer Document Name

    ok, i have resolved my problem. i did what CVMichael told me and almost worked, but i had another problem. in my changename function i also wanted to change the username of the file, and that caused me problems, so i removed it and now it works fine. thanks a lot!

    VB Code:
    1. Public Sub ChangeName(ByVal new_name As String)
    2.     Dim vbPrinter As ApiPrinter
    3.     Dim vbJob As ApiPrintJob
    4.    
    5.     Set vbPrinter = New ApiPrinter
    6.     vbPrinter.DeviceName = Printer.DeviceName
    7.    
    8.     For Each vbJob In vbPrinter.PrintJobs
    9.         '"Microsoft Visual Basic" when debugging the program and "Mosaicos" for the compiled .exe
    10.         If vbJob.DocumentName = "Microsoft Visual Basic" Or vbJob.DocumentName = "Mosaicos" Then
    11.             vbJob.DocumentName = new_name
    12.             'vbJob.UserName = client_name
    13.             Exit For
    14.         End If
    15.     Next vbJob
    16. End Sub
    Last edited by Zerodyme; Jan 8th, 2007 at 03:01 AM.

  26. #26
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: [RESOLVED] Printer Document Name

    VB Code:
    1. 'vbJob.UserName = client_name

    This will throw an error if the user is not known to the server or if that user does not have sufficient access rights. If you just want a different user to be notified of the job progress you need to set the .Notifyuser property instead.

  27. #27
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: [RESOLVED] Printer Document Name

    Is there a way to disable then reenablee the "Save As" dialog box for all printers in general? I specifically want to disable it for PDF writers but I guess that it needs general regardless of printer types as I won't know the name given to specifiv PDF writers.

    I just don't want to have to ask users to download PDFCreator and run them through the steps required to allow saving without the dialog box.

  28. #28
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: [RESOLVED] Printer Document Name

    The source code (in VB) for PDFCreator is available, so you can use (and customise) parts of it in your project if you want.

  29. #29
    Registered User
    Join Date
    Jul 2015
    Posts
    1

    Re: [RESOLVED] Printer Document Name

    Quote Originally Posted by sgrya1 View Post
    I don't surpose anyone has an idea on where the string variable containing "Microsoft Visual Basic" (or the program executable title) is stored? If this were able to be changed then...
    Bit of a Late reply here

    But you can just set app.title = "Job Name you Want" before you start the print routine.

    Much easier

  30. #30
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] Printer Document Name

    Welcome to the forum!

    Yes - really late reply!

    Your answer does not talk to the point of the thread at all. It answers a silly question that had nothing to do with the thread.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  31. #31
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: [RESOLVED] Printer Document Name

    Quote Originally Posted by szlamany View Post
    Welcome to the forum!

    Yes - really late reply!

    Your answer does not talk to the point of the thread at all. It answers a silly question that had nothing to do with the thread.
    I think it does...

    Why don't you check it out yourself - I just did so,
    placing the following in a new StdExe-Project:

    Code:
    Option Explicit
    
    Private Sub Form_Click()
    Dim OldTitle As String
      OldTitle = App.Title
    
        App.Title = "Job Name you Want"
          Printer.Print "Hollow void"
        Printer.EndDoc
    
      App.Title = OldTitle
    End Sub
    Then I've compiled this little Executable - started the Binary -
    clicked the Form - and what was popping up (a PDF-Printer
    being my default here) was:



    As you see, the Printer-API which works underneath of VBs Printing-Functionality,
    will take over the current App.Title as the Document-Name for the PrintJob in question.

    That was all haydos was saying...
    (it's a workaround for the problem, known for years - but wasn't mentioned in this thread here)

    Olaf

  32. #32
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] Printer Document Name

    Changing the title of the app to get a print job name might work - certainly not something I would do.

    The thread, imo, is about getting a PDF driver to pickup a job name.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  33. #33
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: [RESOLVED] Printer Document Name

    Quote Originally Posted by szlamany View Post
    The thread, imo, is about getting a PDF driver to pickup a job name.
    And the PDF-Driver in question does this just fine, when you look at the ScreenShot I've posted.

    Olaf

  34. #34
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: [RESOLVED] Printer Document Name

    Here's another variant, which doesn't wait with Resetting the App-Title
    until the whole Document was printed (encapsulated in a small Routine,
    which only performs a very fast "Printer-No-Op" and then returns):

    Code:
    Option Explicit
    
    Private Sub Form_Click()
        Printer_StartDoc "Another Job-Name"
          Printer.Print "Hollow void"
        Printer.EndDoc
    End Sub
     
    Sub Printer_StartDoc(DocName As String)
    Dim OldTitle As String
        OldTitle = App.Title
        App.Title = DocName
          Printer.Print " ";   'do a No-Op on the Printer, to init the Document
          Printer.CurrentX = 0 'reset the Cursor (due to the Space we printed)
        App.Title = OldTitle   'reset the App.Title to its former value
    End Sub
    Olaf

  35. #35

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    Re: [RESOLVED] Printer Document Name

    Nice !

    9 years late though

  36. #36
    Addicted Member
    Join Date
    Feb 2004
    Posts
    145

    Re: [RESOLVED] Printer Document Name

    [QUOTE=Schmidt;4901139]Here's another variant, which doesn't wait with Resetting the App
    This works perfectly! Seems to work great for all OS's except for Win10? Any reason why the method doesn't work for Win10? Any easy fix?
    /Jimboat

  37. #37
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: [RESOLVED] Printer Document Name

    Quote Originally Posted by Jimboat View Post
    ...Seems to work great for all OS's except for Win10? Any reason why the method doesn't work for Win10? Any easy fix?
    Maybe it is just a "timing"-issue ... meaning the App.Title might have to "stand there" a bit longer...

    A short test, where you comment out the last line which resets to the old, previous title should help
    to determine whether this is a timing-thing or a general problem on Win10.

    Olaf

  38. #38
    Addicted Member
    Join Date
    Feb 2004
    Posts
    145

    Re: [RESOLVED] Printer Document Name

    Quote Originally Posted by Schmidt View Post
    Maybe it is just a "timing"-issue ... meaning the App.Title might have to "stand there" a bit longer...

    A short test, where you comment out the last line which resets to the old, previous title should help
    to determine whether this is a timing-thing or a general problem on Win10. /Olaf
    Olaf - thanks for the suggestion. I tried your test, but Win10 still doesn't pick up the app name.title at all (Win10 just takes to printer with name = "".

    must be a Win10 problem. it'd be nice if we had a work-around for it?
    /Jimboat

  39. #39
    Addicted Member
    Join Date
    Feb 2004
    Posts
    145

    Re: [RESOLVED] Printer Document Name

    Still can't get this to work. Does anyone know of a work-around?
    /Jimboat

  40. #40
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: [RESOLVED] Printer Document Name

    Quote Originally Posted by Jimboat View Post
    Still can't get this to work. Does anyone know of a work-around?
    Seems that the little trick over the App.Title is not working anymore on Win10...

    So you will have to print per Win32-API then (StartDoc/EndDoc, StartPage/EndPage etc.), using only the Printer.hDC for rendering.

    There's a few wrappers for that out there (either in form of a "PrinterObject"-encapsulation or in form of a "Printer-Dialogue" encapsulation).

    For a fast check on Win10, you could use the EMF-based Printing-Encapsulation from vbRichClient5 (cReportDocument, cReportPage).
    This allows, to build up your page(s) InMemory first - preview them on a given Form or PictureBox -
    and then finally print them all in one go - to a Printer of your choice (from the VB6-Printers-Collection, including a Document-Title).

    I've posted a small Demo-Zip (based on code from Wolfgang Wolff) in the following thread (in post #9):
    http://www.vbforums.com/showthread.p...=1#post4906853

    Let me know, how that works out with regards to document-titles on Win10...

    Olaf

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