Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Problem with Excel PageSetup class

Posted on 2003-02-27
Medium Priority
Last Modified: 2012-06-27
I found this error when i try to use PageSetup class in my web project that create by VB.NET

Unable to set the LeftMargin property of the PageSetup class
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Unable to set the LeftMargin property of the PageSetup class

my VB code is below.

dim xlApp as Excel.Application
dim xlWb as Excel.Workbook
dim xlWs as Excel.Worksheet

xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlWb = xlApp.Workbooks.Add
xlWs = xlWb.Worksheets("Sheet1")

xlWs.PageSetup.LeftFooter = Format$(Now, "d/M/yyyy")

If i remark this line, I can create an Excel file without
any error. Does anyone can put me to the right way?

Thanks in advance,
Question by:ultra2
LVL 70

Expert Comment

by:Éric Moreau
ID: 8039099
I had some problems with the PageSetup object when I had no printer defined on a PC. Do you have a printer installed?

Author Comment

ID: 8039248
I has a network priter install on my PC.
LVL 20

Accepted Solution

Michel Sakr earned 200 total points
ID: 8040104
You should install the printer for the account that is launching the application.. log in using this account and set a network printer for it since network printers are like mapped shares (they are after all) and they are user specific unlike local printers. if you are developing a web application the simply impersonate to an account that have enough privilieges and have a mapped printer
LVL 96

Expert Comment

by:Bob Learned
ID: 9649966
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by Silvers5

Please leave any comments here within the next seven days.


EE Cleanup Volunteer

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 1 hour left to enroll

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question