Hi everyone,

I'm new to this forum and mainly use C# and I am a bit stuck now with a VBA code (which I use for our Word templates and printing macro).

I have been following thread (http://www.vbforums.com/showthread.p...or-a-print-job) to change the username of a print job.

I am stuck in the sub SavePrintJobInfo() with buffer(3) = LPCSTR(.lpUserName). What is the purpose of the function/sub LPCSTR, as there are no declarations for it or any examples.

I figured that it is supposed to convert the string value (.lpUsername) into a long value as buffer is declared as a long array (Private buffer() As Long).

I tried the following, but I get a type mismatch error:
Code:
Private Function LPCSTR(str As String) As Long

LPCSTR = CLng(str)

End Function
I then changed it to LPCSTR = CLng(Val(str)), but now I get a "Subscript out of range" error.

Can someone please assist with this?