Results 1 to 13 of 13
  1. #1
    New Lounger
    Join Date
    Dec 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating a prn file on word xp computer (Word XP)

    I have a s question related to printing to file in word.

    sPrintName = sOutPrefix & "ClaimsForm.prn"
    o.ActiveWindow.View.Type = wdPageView
    o.ActiveDocument.PrintOut PrintToFile:=True,OutputFileName:=sPrintName
    o.ActiveDocument.Protect Type:=wdAllowOnlyComments, Password:="haht"

    When I use this code in a Window 2000 server/ Word XP computer which is recently configured
    I get an error message which says --
    WORD CANOT PRINT . There is no printer installed
    error number- 2146823148


    There is HP LASER JET 4000 series PCL 6 printer on the computer.
    Can anyone please point out the cause of error.
    Is it code or do we need anything special while installing printer to create a prn file

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Creating a prn file on word xp computer (Word XP)

    I tried your code (leaving out the o. in front of various lines) and it worked fine for me.
    Have you set a default printer?

    StuartR

  3. #3
    New Lounger
    Join Date
    Dec 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a prn file on word xp computer (Word XP)

    Yes I have default printer set on the server where I am trying to create the prn files. I am able to print fine from server where printer is installed

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Creating a prn file on word xp computer (Word XP)

    I am sorry but I don't understand your last message.

    It sounds like you have two or more different servers. If you are telling us that you get an error printing from a server when there is no printer installed then this is expected behaviour.

    Can you describe the configuration of each server in terms of
    <UL><LI>Does it have a printer installed?
    <LI>What is the default printer?
    <LI>Does your macro give errors?[/list]StuartR

  5. #5
    New Lounger
    Join Date
    Dec 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a prn file on word xp computer (Word XP)

    We have an intranet based system where we can-
    1. Print word document directly to a network printer'
    2. Download a word document on internet.

    When I am trying to download a word document I use this code---

    Set o = CreateObject("Word.Application")
    o.Documents.Open FileName:=sFileName

    sDocName = "1.doc"
    sPrintName = "1.prn"
    o.ActiveWindow.View.Type = wdPageView
    o.ActiveDocument.PrintOut PrintToFile:=True,OutputFileName:=sPrintName
    o.ActiveDocument.Protect Type:=wdAllowOnlyComments, Password:="abcd"
    o.ActiveDocument.SaveAs FileName:=sDocName
    o.Quit SaveChanges:=wdDoNotSaveChanges
    Set o = Nothing

    this line gives this error during error trap-
    o.ActiveDocument.PrintOut PrintToFile:=True,OutputFileName:=sPrintName

    error is- *word canot print. There is no printer installed* err number- 2146823148
    If I comment out this line everthing works fine. But i need to create a prn file on server
    to force word to format word document before saving it.

    #####Can you describe the configuration of each server in terms of

    Does it have a printer installed?
    Yes server has printer installed. If I print document directly to printer from server it works fine. It shows the printer installation on server is fine

    What is the default printer?
    Yes Default printer is also set



    Does your macro give errors?
    I have no idea about this point. I donot use word macro.

    thanks

  6. #6
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Creating a prn file on word xp computer (Word XP)

    I'm starting to understand.

    When you print the document yourself are you logged into your own account on the server?
    When you run this code on the server what username does it run under? Is there a default printer for that user? Does this user have access rights to the printer?

    StuartR

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Creating a prn file on word xp computer (Word XP)

    If you insert:

    MsgBox o.ActivePrinter

    prior to the PrintOut method, what do you get? Nothing? Maybe this is a flaw of some kind of the automation model, but I'm pretty sure I've seen other VBA procedures on this board that use .PrintOut successfully for "bulk" printing.

  8. #8
    New Lounger
    Join Date
    Dec 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a prn file on word xp computer (Word XP)

    When you print the document yourself are you logged into your own account on the server?
    yes

    When you run this code on the server what username does it run under? Is there a default printer for that user? Does this user have access rights to the printer?
    I am not sure about this. The same code works fine in other server. This is a newly config server.I am able to create a prn file on server
    if I go to server and open a word doc and use FILEPRINTPRINT TO FILE

    Could you please tell me
    1. Does creating prn file needs some special driver to be installed on server
    2. How does access rights affects prn file creation ? As I am able to print and even downlaod document on internet if I donot create prn file

    I think its issue related to printer configuaraion or access rights which I am not able to understand.

    thanks

  9. #9
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Creating a prn file on word xp computer (Word XP)

    It is starting to sound as though this is very probably an issue to do with the username under which the document is being printed.

    What operating system is this server running?
    How are you creating this Word.Application? Is it from a web server running IIS, or some other mechanism?
    Did you try Jefferson's suggestion of MsgBox o.ActivePrinter, this would help us to understand whether there is a default printer for this user.

    It's getting late here in the UK and I'm off to bed now, hopefully I will see how you resolved this when I wake up in the morning <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    StuartR

  10. #10
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Creating a prn file on word xp computer (Word XP)

    > But i need to create a prn file on server to force word to format word document before saving it.

    Can you explain this part a little bit more? Is sFileName not already in Word format? not properly paginated?

  11. #11
    New Lounger
    Join Date
    Dec 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a prn file on word xp computer (Word XP)

    MsgBox o.ActivePrinter returns the correct default printer name when I run a word macro directly on the server.

    Using word macro I am able to create prn file and append another word file in that prn file when I do it directly on the server.

    Using IIS
    =======

    I added one line of code to assign default printer --
    o.WordBasic.FilePrintSetup Printer:="PINDJDQ1 on HPLASERJET4100SERIES", _
    DoNotSetAsSysDefault:=0

    With this change I was able to create prn file.

    So the final result is that I am not able to get the Default printer name though default printer is assigned correctly on the server.

    Stuart,

    Any idea what user access rights chnages do I need to make on Window 2000/IIS server , so that I can get the default printer name without explicitely assigning the value. Explicit assignment will not work in my case because our application uses large number of printer installed on server.

    thanks for all your suggestions

    Raj

  12. #12
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Creating a prn file on word xp computer (Word XP)

    It seems an administrator could add one or more printers for the Anonymous IIS User (or whatever it's username is), but this would only provide for one default printer for IIS, regardless of the actual end user. Do you need the printer to be user-specific?

  13. #13
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Creating a prn file on word xp computer (Word XP)

    There are a number of other problems that Word can suffer from when you run it in this way. It would be a good idea to read the article INFO: Considerations for Server-Side Automation of Office on the Microsoft web site.

    There is an example of a login script that assigns a default printer on the Microsoft web site in article 304767

    StuartR

Posting Permissions

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