Problem with Excel PageSetup class

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,
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
I had some problems with the PageSetup object when I had no printer defined on a PC. Do you have a printer installed?
ultra2Author Commented:
I has a network priter install on my PC.
Michel SakrCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob LearnedCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.