.NET makes it impossible to print from Excel 2003???
-
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.Documentmoapp = 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
-
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.Documentmoapp = 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
If this is the actual code you are running, why is the .PrintOut statement commented out?
-
If this is the actual code you are running, why is the .PrintOut statement commented out?
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...