Answered Print Program Question

harish.svhk

New member
Joined
Sep 27, 2020
Messages
1
Programming Experience
10+
Good Morning Dean,

I am looking for this, to change the owner name of the print given through c# code, but for me it is showing only the owner name always as system logged in user.
Following are the code I am using to print from button click, but owner is always Administrator which is the logged in user of the computer.
Can you please help me here, appreciate your response either way.

Thank You
Harish

1601210821589.png


C#:
                TrayName = "0";
                PrinterName = "HP Ink Tank Wireless 410 series";
                //PrinterName = "DIRECT-58-HP Ink Tank Wireless";
                Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
                Document wordDoc = new Document();
                object objBackground = true;
                Object oMissing = System.Reflection.Missing.Value;
                Object oTemplatePath = FilePath;
                Object oNoOfCopies = 3;
                wordApp.ActivePrinter = PrinterName;
                wordDoc = wordApp.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);
                PrintDocument pd = new PrintDocument();
                pd.PrinterSettings.PrinterName = PrinterName;
                pd.DocumentName = "Test Print...";
                wordApp.UserName = "Harish";
                wordApp.PrintOut(oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oNoOfCopies, oMissing, oMissing);
 
Last edited by a moderator:
Welcome to the forums @harish.svhk -

Your questions and contributions are welcomed on the forums, however, this topic is almost 5 years old. I'm sure the user has since either moved on or found a solution and unlikely to reply. Please check the dates on topics before replying to them.

If you need help, then you should open your own topic, and link to the original post for reference. I will split this topic for you.
 
Last edited:
Unfortunately, the wordapp.UserName on line 15 maps to this Word Object Model Application.UserName which as per the documentation is not about printing:
Returns or sets the user's name, which is used on envelopes and for the Author document property.

Anyway, as best as I recall from the Win32 printing API, there is no way to change the name of the owner of the print job without actually changing the identity of the running program before submitting the print job. Why would you want to change the owner of a print job? That sounds like a really odd thing to do. Imagine Malory a few cubicles down printing out all the company financials and putting in Alice's name as owner of the print job.
 
Last edited:
Back
Top Bottom