|
-
May 20th, 2013, 04:01 AM
#1
Thread Starter
New Member
VBA - Changing the username of a print job
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?
-
May 20th, 2013, 08:00 AM
#2
Re: VBA - Changing the username of a print job
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|