?
Solved

Problem with Excel PageSetup class

Posted on 2003-02-27
5
Medium Priority
?
1,617 Views
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,
Gap
0
Comment
Question by:ultra2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
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?
0
 

Author Comment

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

Accepted Solution

by:
Silvers5 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
0
 
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.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

771 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