Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 3 of 3

Thread: [Solved] Printing: Error 1004 when attempting to set ActiveP

  1. #1
    Join Date
    11th August 2003
    Posts
    2
    I have a VB project, where for years, the code internally referenced the Excel object. So when setting the ActivePrinter property of the Application object it was simply a matter of assigning the property like such:

    Set xlApp = New Excel.Application
    xlApp.ActivePrinter = strPrinterName

    Now I have to deploy the same application to various platforms. The primary is a Windows 95 (yeah I know... most us can't even remember what it looks like), and also to Win2K and WinXP. The Win95 platforms runs Office 97, the Win2K platform runs Office 2K, and WinXP runs Office 2003. The development machine runs the Win2K/Office2K combo.

    So to save stuffing about I changed the code the create the Excel object using CreateObject and removed the internal reference. So the code now looks like this:

    Set xlApp = CreateObject("Excel.Application")
    xlApp.ActivePrinter = strPrinterName

    Now for some odd reason M$ have made the ActivePrinter property read-only when the Application object is instantiated using CreateObject. I now get the error:
    "Unable to set the ActivePrinter property of the Application class".

    Does anyone know a work-around for this problem? I can't just assume the ActivePrinter property is defaulted to the correct printer, because the program sets the printer based on whether the report it has to print is in colour or just black-and-white. Save compiling the application on each target platform and changing the referencing back to internal, I don't know what to do.

    Can anyone help?

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    11th August 2003
    Posts
    2
    The ActivePrinter property of the Application class is read-only when the object is instantiated using CreateObject. To get around this problem you can pass the printer in as an option when calling the PrintOut method:

    xlWorksheet.PrintOut ActivePrinter:=strPrinterName

    NB. This is not the case with the Word application class. The ActivePrinter property can be set (is not read-only) at runtime when the Application class has been instantiated using CreateObject. Go figure!

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    20th May 2003
    Location
    Mesa, Az
    Posts
    1,110
    I have read several of the many posts that are on this forum and think that perhaps this is the first one where the person posting the question also was the person answering the post!!

    As far as your solution, how typical of M$ to "standardize" their applications differently!

Thread Information

Users Browsing this Thread

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

Possible Answers

  1. [Solved] Error 1004 - due to copying?
    By Woody93 in forum EXCEL HELP
    Replies: 1
    Last Post: March 29th, 2004, 10:17
  2. Replies: 2
    Last Post: March 3rd, 2004, 22:37
  3. Replies: 5
    Last Post: September 8th, 2003, 01:35
  4. Replies: 4
    Last Post: September 5th, 2003, 02:54

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
  •  
porno