Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. .NET makes it impossible to print from Excel 2003???

.NET makes it impossible to print from Excel 2003???

Scheduled Pinned Locked Moved Visual Basic
csharpsharepointcomhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mSh1985
    wrote on last edited by
    #1

    Hi, I have an vb.net application that opens a word document, fills in some data, prints it out (on a printer that is not set as standard printer) Because .NET sets the other printer as standard, i have another line that puts the original printer back as standard printer When this program was used, it is impossible to print something from excel 2003... Something in my program does something to excel apparently :confused: This is the code i use (short version)

    Imports wrd = Microsoft.Office.Interop
    Module Module1
    Sub Main()
    Dim moapp As wrd.Word.Application
    Dim odoc As wrd.Word.Document

        moapp = New wrd.Word.ApplicationClass().Application
        moapp.Visible = False
    
        odoc = moapp.Documents.Add("C:\\Documents and Settings\\9312323\\Desktop\\excelbug.doc")
    
        moapp.ActivePrinter = "\\\\N318416\\PRINT068 NRG SP 4100N"
        'With moapp.ActiveDocument.PageSetup
        '    .FirstPageTray = 258
        '    .OtherPagesTray = 258
        'End With
        'moapp.Application.PrintOut(FileName:="", Range:=wrd.Word.WdPrintOutRange.wdPrintAllDocument, Item:= \_
        '     wrd.Word.WdPrintOutItem.wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wrd.Word.WdPrintOutPages.wdPrintAllPages, \_
        '     ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= \_
        '     False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, \_
        '     PrintZoomPaperHeight:=0)
    
        moapp.ActivePrinter = "\\\\N318416\\PRINT019 NRG P7527n"
        odoc.Close(False)
        moapp.Quit()
    End Sub
    

    End Module

    Has anyone got an idea how to work around this problem? My application works just fine.. but Excel 2003 can't print anymore if someone won't believe this, just copy the code in a new project, add reference to microsoft word 11.0 object library, and run it , then try to print something from excel (without changing printer first) grtz edit: if you should try the code, i would recommend on changing the printernames ;P

    T 1 Reply Last reply
    0
    • M mSh1985

      Hi, I have an vb.net application that opens a word document, fills in some data, prints it out (on a printer that is not set as standard printer) Because .NET sets the other printer as standard, i have another line that puts the original printer back as standard printer When this program was used, it is impossible to print something from excel 2003... Something in my program does something to excel apparently :confused: This is the code i use (short version)

      Imports wrd = Microsoft.Office.Interop
      Module Module1
      Sub Main()
      Dim moapp As wrd.Word.Application
      Dim odoc As wrd.Word.Document

          moapp = New wrd.Word.ApplicationClass().Application
          moapp.Visible = False
      
          odoc = moapp.Documents.Add("C:\\Documents and Settings\\9312323\\Desktop\\excelbug.doc")
      
          moapp.ActivePrinter = "\\\\N318416\\PRINT068 NRG SP 4100N"
          'With moapp.ActiveDocument.PageSetup
          '    .FirstPageTray = 258
          '    .OtherPagesTray = 258
          'End With
          'moapp.Application.PrintOut(FileName:="", Range:=wrd.Word.WdPrintOutRange.wdPrintAllDocument, Item:= \_
          '     wrd.Word.WdPrintOutItem.wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wrd.Word.WdPrintOutPages.wdPrintAllPages, \_
          '     ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= \_
          '     False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, \_
          '     PrintZoomPaperHeight:=0)
      
          moapp.ActivePrinter = "\\\\N318416\\PRINT019 NRG P7527n"
          odoc.Close(False)
          moapp.Quit()
      End Sub
      

      End Module

      Has anyone got an idea how to work around this problem? My application works just fine.. but Excel 2003 can't print anymore if someone won't believe this, just copy the code in a new project, add reference to microsoft word 11.0 object library, and run it , then try to print something from excel (without changing printer first) grtz edit: if you should try the code, i would recommend on changing the printernames ;P

      T Offline
      T Offline
      Tim Carmichael
      wrote on last edited by
      #2

      If this is the actual code you are running, why is the .PrintOut statement commented out?

      M 1 Reply Last reply
      0
      • T Tim Carmichael

        If this is the actual code you are running, why is the .PrintOut statement commented out?

        M Offline
        M Offline
        mSh1985
        wrote on last edited by
        #3

        tnx for your reply this is not the actual code from the program, but it is however the actual code from a testprogram i wrote to simulate the problem. I commented out those lines so i did not have to print out a document every time i wanted to simulate the problem so running the code above will result in excel not being able to print...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups