+ Reply to Thread
Results 1 to 5 of 5

Minor Problem with Macro

Hybrid View

  1. #1
    Brad
    Guest

    Minor Problem with Macro

    Hello,

    I have a macro that works. The issue I am having is it changes my default
    printer. In the macro, I call upon the Microsoft Document driver to speed up
    the macro. By doing this, it changes the printer for Excel to this Document
    Driver. What code can I use to call upon the previous printer (what ever the
    user's default printer is) so that when they print through Excel it will be
    back to the default printer. Here is my code (condensed for easier reading):

    Thanks in advance.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Sub Addon()
    '
    ' Addon Macro
    ' Addon recorded 2/6/2004 by bhodge
    '

    '
    Application.EnableEvents = False
    On Error Resume Next
    Application.ActivePrinter = "Microsoft Office Document Image Writer on
    Ne02:"
    If Err.Number = 1004 Then
    Application.ActivePrinter = "Microsoft Office Document Image Writer on Ne01:"
    Err.Clear
    End If
    Dim AWB As Workbook
    Set AWB = ActiveWorkbook
    Application.ScreenUpdating = False
    AWB.Activate
    Workbooks.Open Filename:= _
    "G:\Contract QuoteTemplates\Email Template Macro3l.xls"
    AWB.Activate
    Windows("Email Template Macro3l.xls").Activate
    Sheets("Features").Select
    Sheets.Add
    Sheets("Sheet1").Select
    Sheets("Sheet1").Move after:=Sheets(2)
    Sheets("Sheet1").Name = "Terms and Conditions"
    AWB.Activate
    Sheets("Terms and Conditions").Select
    Cells.Select
    Selection.Copy
    Application.ScreenUpdating = True
    Range("a25").Select
    Application.EnableEvents = True
    RemoveAllCode
    End With
    End Sub




  2. #2
    Tom Ogilvy
    Guest

    Re: Minor Problem with Macro

    Sub Addon()
    '
    ' Addon Macro
    ' Addon recorded 2/6/2004 by bhodge
    '

    '
    Dim sStr as String
    sStr = Application.ActivePrinter
    Application.EnableEvents = False
    On Error Resume Next
    Application.ActivePrinter = "Microsoft Office Document Image Writer on
    Ne02:"
    If Err.Number = 1004 Then
    Application.ActivePrinter = "Microsoft Office Document Image Writer on
    Ne01:"
    Err.Clear
    End If
    Dim AWB As Workbook
    Set AWB = ActiveWorkbook
    Application.ScreenUpdating = False
    AWB.Activate
    Workbooks.Open Filename:= _
    "G:\Contract QuoteTemplates\Email Template Macro3l.xls"
    AWB.Activate
    Windows("Email Template Macro3l.xls").Activate
    Sheets("Features").Select
    Sheets.Add
    Sheets("Sheet1").Select
    Sheets("Sheet1").Move after:=Sheets(2)
    Sheets("Sheet1").Name = "Terms and Conditions"
    AWB.Activate
    Sheets("Terms and Conditions").Select
    Cells.Select
    Selection.Copy
    Application.ScreenUpdating = True
    Range("a25").Select
    Application.EnableEvents = True
    RemoveAllCode
    End With
    ' NOW change it back
    Application.ActiveWorkbook = sStr
    End Sub

    --
    Regards,
    Tom Ogilvy


    "Brad" <[email protected]> wrote in message
    news:[email protected]...
    > Hello,
    >
    > I have a macro that works. The issue I am having is it changes my default
    > printer. In the macro, I call upon the Microsoft Document driver to speed

    up
    > the macro. By doing this, it changes the printer for Excel to this

    Document
    > Driver. What code can I use to call upon the previous printer (what ever

    the
    > user's default printer is) so that when they print through Excel it will

    be
    > back to the default printer. Here is my code (condensed for easier

    reading):
    >
    > Thanks in advance.
    >
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > Sub Addon()
    > '
    > ' Addon Macro
    > ' Addon recorded 2/6/2004 by bhodge
    > '
    >
    > '
    > Application.EnableEvents = False
    > On Error Resume Next
    > Application.ActivePrinter = "Microsoft Office Document Image Writer on
    > Ne02:"
    > If Err.Number = 1004 Then
    > Application.ActivePrinter = "Microsoft Office Document Image Writer on

    Ne01:"
    > Err.Clear
    > End If
    > Dim AWB As Workbook
    > Set AWB = ActiveWorkbook
    > Application.ScreenUpdating = False
    > AWB.Activate
    > Workbooks.Open Filename:= _
    > "G:\Contract QuoteTemplates\Email Template Macro3l.xls"
    > AWB.Activate
    > Windows("Email Template Macro3l.xls").Activate
    > Sheets("Features").Select
    > Sheets.Add
    > Sheets("Sheet1").Select
    > Sheets("Sheet1").Move after:=Sheets(2)
    > Sheets("Sheet1").Name = "Terms and Conditions"
    > AWB.Activate
    > Sheets("Terms and Conditions").Select
    > Cells.Select
    > Selection.Copy
    > Application.ScreenUpdating = True
    > Range("a25").Select
    > Application.EnableEvents = True
    > RemoveAllCode
    > End With
    > End Sub
    >
    >
    >




  3. #3
    Brad
    Guest

    Re: Minor Problem with Macro

    Tom, thanks for replying, however it still isn't working. I stepped into the
    macro with your code and had the Printer Panel up while stepping in. It looks
    like the macro never changes the OS default printer, it is only changing
    Excel's Default Printer. Any ideas? Thanks.

    "Tom Ogilvy" wrote:

    > Sub Addon()
    > '
    > ' Addon Macro
    > ' Addon recorded 2/6/2004 by bhodge
    > '
    >
    > '
    > Dim sStr as String
    > sStr = Application.ActivePrinter
    > Application.EnableEvents = False
    > On Error Resume Next
    > Application.ActivePrinter = "Microsoft Office Document Image Writer on
    > Ne02:"
    > If Err.Number = 1004 Then
    > Application.ActivePrinter = "Microsoft Office Document Image Writer on
    > Ne01:"
    > Err.Clear
    > End If
    > Dim AWB As Workbook
    > Set AWB = ActiveWorkbook
    > Application.ScreenUpdating = False
    > AWB.Activate
    > Workbooks.Open Filename:= _
    > "G:\Contract QuoteTemplates\Email Template Macro3l.xls"
    > AWB.Activate
    > Windows("Email Template Macro3l.xls").Activate
    > Sheets("Features").Select
    > Sheets.Add
    > Sheets("Sheet1").Select
    > Sheets("Sheet1").Move after:=Sheets(2)
    > Sheets("Sheet1").Name = "Terms and Conditions"
    > AWB.Activate
    > Sheets("Terms and Conditions").Select
    > Cells.Select
    > Selection.Copy
    > Application.ScreenUpdating = True
    > Range("a25").Select
    > Application.EnableEvents = True
    > RemoveAllCode
    > End With
    > ' NOW change it back
    > Application.ActiveWorkbook = sStr
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Brad" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hello,
    > >
    > > I have a macro that works. The issue I am having is it changes my default
    > > printer. In the macro, I call upon the Microsoft Document driver to speed

    > up
    > > the macro. By doing this, it changes the printer for Excel to this

    > Document
    > > Driver. What code can I use to call upon the previous printer (what ever

    > the
    > > user's default printer is) so that when they print through Excel it will

    > be
    > > back to the default printer. Here is my code (condensed for easier

    > reading):
    > >
    > > Thanks in advance.
    > >
    > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > > Sub Addon()
    > > '
    > > ' Addon Macro
    > > ' Addon recorded 2/6/2004 by bhodge
    > > '
    > >
    > > '
    > > Application.EnableEvents = False
    > > On Error Resume Next
    > > Application.ActivePrinter = "Microsoft Office Document Image Writer on
    > > Ne02:"
    > > If Err.Number = 1004 Then
    > > Application.ActivePrinter = "Microsoft Office Document Image Writer on

    > Ne01:"
    > > Err.Clear
    > > End If
    > > Dim AWB As Workbook
    > > Set AWB = ActiveWorkbook
    > > Application.ScreenUpdating = False
    > > AWB.Activate
    > > Workbooks.Open Filename:= _
    > > "G:\Contract QuoteTemplates\Email Template Macro3l.xls"
    > > AWB.Activate
    > > Windows("Email Template Macro3l.xls").Activate
    > > Sheets("Features").Select
    > > Sheets.Add
    > > Sheets("Sheet1").Select
    > > Sheets("Sheet1").Move after:=Sheets(2)
    > > Sheets("Sheet1").Name = "Terms and Conditions"
    > > AWB.Activate
    > > Sheets("Terms and Conditions").Select
    > > Cells.Select
    > > Selection.Copy
    > > Application.ScreenUpdating = True
    > > Range("a25").Select
    > > Application.EnableEvents = True
    > > RemoveAllCode
    > > End With
    > > End Sub
    > >
    > >
    > >

    >
    >
    >


  4. #4
    Tom Ogilvy
    Guest

    Re: Minor Problem with Macro

    Sorry, didn't recognize what you are asking:

    http://support.microsoft.com/default...b;en-us;266767
    HOWTO: Set Which Printer Is the System Default Printer

    --
    Regards,
    Tom Ogilvy

    "Brad" <[email protected]> wrote in message
    news:[email protected]...
    > Tom, thanks for replying, however it still isn't working. I stepped into

    the
    > macro with your code and had the Printer Panel up while stepping in. It

    looks
    > like the macro never changes the OS default printer, it is only changing
    > Excel's Default Printer. Any ideas? Thanks.
    >
    > "Tom Ogilvy" wrote:
    >
    > > Sub Addon()
    > > '
    > > ' Addon Macro
    > > ' Addon recorded 2/6/2004 by bhodge
    > > '
    > >
    > > '
    > > Dim sStr as String
    > > sStr = Application.ActivePrinter
    > > Application.EnableEvents = False
    > > On Error Resume Next
    > > Application.ActivePrinter = "Microsoft Office Document Image Writer

    on
    > > Ne02:"
    > > If Err.Number = 1004 Then
    > > Application.ActivePrinter = "Microsoft Office Document Image Writer on
    > > Ne01:"
    > > Err.Clear
    > > End If
    > > Dim AWB As Workbook
    > > Set AWB = ActiveWorkbook
    > > Application.ScreenUpdating = False
    > > AWB.Activate
    > > Workbooks.Open Filename:= _
    > > "G:\Contract QuoteTemplates\Email Template Macro3l.xls"
    > > AWB.Activate
    > > Windows("Email Template Macro3l.xls").Activate
    > > Sheets("Features").Select
    > > Sheets.Add
    > > Sheets("Sheet1").Select
    > > Sheets("Sheet1").Move after:=Sheets(2)
    > > Sheets("Sheet1").Name = "Terms and Conditions"
    > > AWB.Activate
    > > Sheets("Terms and Conditions").Select
    > > Cells.Select
    > > Selection.Copy
    > > Application.ScreenUpdating = True
    > > Range("a25").Select
    > > Application.EnableEvents = True
    > > RemoveAllCode
    > > End With
    > > ' NOW change it back
    > > Application.ActiveWorkbook = sStr
    > > End Sub
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "Brad" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Hello,
    > > >
    > > > I have a macro that works. The issue I am having is it changes my

    default
    > > > printer. In the macro, I call upon the Microsoft Document driver to

    speed
    > > up
    > > > the macro. By doing this, it changes the printer for Excel to this

    > > Document
    > > > Driver. What code can I use to call upon the previous printer (what

    ever
    > > the
    > > > user's default printer is) so that when they print through Excel it

    will
    > > be
    > > > back to the default printer. Here is my code (condensed for easier

    > > reading):
    > > >
    > > > Thanks in advance.
    > > >
    > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > > > Sub Addon()
    > > > '
    > > > ' Addon Macro
    > > > ' Addon recorded 2/6/2004 by bhodge
    > > > '
    > > >
    > > > '
    > > > Application.EnableEvents = False
    > > > On Error Resume Next
    > > > Application.ActivePrinter = "Microsoft Office Document Image

    Writer on
    > > > Ne02:"
    > > > If Err.Number = 1004 Then
    > > > Application.ActivePrinter = "Microsoft Office Document Image Writer on

    > > Ne01:"
    > > > Err.Clear
    > > > End If
    > > > Dim AWB As Workbook
    > > > Set AWB = ActiveWorkbook
    > > > Application.ScreenUpdating = False
    > > > AWB.Activate
    > > > Workbooks.Open Filename:= _
    > > > "G:\Contract QuoteTemplates\Email Template Macro3l.xls"
    > > > AWB.Activate
    > > > Windows("Email Template Macro3l.xls").Activate
    > > > Sheets("Features").Select
    > > > Sheets.Add
    > > > Sheets("Sheet1").Select
    > > > Sheets("Sheet1").Move after:=Sheets(2)
    > > > Sheets("Sheet1").Name = "Terms and Conditions"
    > > > AWB.Activate
    > > > Sheets("Terms and Conditions").Select
    > > > Cells.Select
    > > > Selection.Copy
    > > > Application.ScreenUpdating = True
    > > > Range("a25").Select
    > > > Application.EnableEvents = True
    > > > RemoveAllCode
    > > > End With
    > > > End Sub
    > > >
    > > >
    > > >

    > >
    > >
    > >




  5. #5
    Ron de Bruin
    Guest

    Re: Minor Problem with Macro

    Hi Brad

    Try this

    Dim DPrinter As String
    DPrinter = Application.ActivePrinter
    Application.ActivePrinter = "Microsoft Office Document Image Writer on Ne01:"

    'print code

    Application.ActivePrinter = DPrinter


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl



    "Brad" <[email protected]> wrote in message news:[email protected]...
    > Hello,
    >
    > I have a macro that works. The issue I am having is it changes my default
    > printer. In the macro, I call upon the Microsoft Document driver to speed up
    > the macro. By doing this, it changes the printer for Excel to this Document
    > Driver. What code can I use to call upon the previous printer (what ever the
    > user's default printer is) so that when they print through Excel it will be
    > back to the default printer. Here is my code (condensed for easier reading):
    >
    > Thanks in advance.
    >
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > Sub Addon()
    > '
    > ' Addon Macro
    > ' Addon recorded 2/6/2004 by bhodge
    > '
    >
    > '
    > Application.EnableEvents = False
    > On Error Resume Next
    > Application.ActivePrinter = "Microsoft Office Document Image Writer on
    > Ne02:"
    > If Err.Number = 1004 Then
    > Application.ActivePrinter = "Microsoft Office Document Image Writer on Ne01:"
    > Err.Clear
    > End If
    > Dim AWB As Workbook
    > Set AWB = ActiveWorkbook
    > Application.ScreenUpdating = False
    > AWB.Activate
    > Workbooks.Open Filename:= _
    > "G:\Contract QuoteTemplates\Email Template Macro3l.xls"
    > AWB.Activate
    > Windows("Email Template Macro3l.xls").Activate
    > Sheets("Features").Select
    > Sheets.Add
    > Sheets("Sheet1").Select
    > Sheets("Sheet1").Move after:=Sheets(2)
    > Sheets("Sheet1").Name = "Terms and Conditions"
    > AWB.Activate
    > Sheets("Terms and Conditions").Select
    > Cells.Select
    > Selection.Copy
    > Application.ScreenUpdating = True
    > Range("a25").Select
    > Application.EnableEvents = True
    > RemoveAllCode
    > End With
    > End Sub
    >
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1