Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Posts
    304
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code to change printer and specify save location (VB 6.3)

    I'm trying to create some macros in Word. Does anyone know the code to change the printer to a specific printer ONLY for the print out of the current document. I have tried using ActivePrinter and that changes my default printer, which I do not want to do. Also, I would like to specify where the document is saved. When I try ChangeFileOpenDirectory and then specify a network path, it gives me a "Runtime Error 4198. Command Failed" Any help would be appreciated as VB is NOT my strong point. Thanks - Sat.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Code to change printer and specify save location (VB 6.3)


  3. #3
    3 Star Lounger
    Join Date
    Apr 2001
    Posts
    304
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code to change printer and specify save location (VB 6.3)

    Thank you Hans for your quick response. Have already tried the Print solution and that works great.

    So I have another, harder question. These macros are running behind buttons on a form that I have created. When running the SaveAs macro, I would like to attempt to pull the name of the saved document from two fields in the form (name and time - name is a fill-in field and time is automatically filled in using a Date field that I inserted). Does this sound possible? Or can you think of a better solution. Since several users are going to use this form, I don't want to specify a static filename as it will keep copying one form over the other every time someone hits the Save button.

    Thanks again.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Code to change printer and specify save location (VB 6.3)

    You can retrieve the value of fields in the document like this:

    ActiveDocument.Fields(3).Result

    or you can create bookmarks Name and Time that coincide with the fields and use

    ActiveDocument.Bookmarks("Name").Range.Text

    So, in the example from the Word MVP site:

    With Dialogs(wdDialogFileSaveAs)
    .Name = "C:MyPath" & ActiveDocument.Bookmarks("Name").Range.Text & _
    ActiveDocument.Bookmarks("Time").Range.Text & ".doc"
    .Show
    End With

Posting Permissions

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