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

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

creating excel page on the fly

   I'm creating excel page on the fly within asp page.  I got one problem on the verticalalignment line.  This work fine in VB but does an error in ASP.  Any idea?

Set oExcel = server.createobject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
Set oSheet = oBook.Worksheets(1)

oSheet.Range("a1") = "Imprimé le :"
osheet.range("b1") = tofrenchdatelong(now)
oSheet.Range("a3") = "Demande"
oSheet.Range("b3") = "Trv"

oSheet.Range("a3:i4").VerticalAlignment = xlVAlignCenter

  • 3
  • 2
1 Solution

Have you declared the constant xlVAlignCenter anywhere?  If not this will be the problem as in vb when you reference the Excel object (as I'm guessing you do) it automatically references the constants but is ASP it doesn't.

Add the following line to start of the ASP and give it another go:

Const xlVAlignCenter = -4108

DanielBlaisAuthor Commented:
i'm so stupid.
DanielBlaisAuthor Commented:
ok, I have another question.  May be you can help me.

I want to change the orientation.

In vb, it works.  In ASP, I got this error :

const xlPortrait = 1
const xlLandscape = 2
oSheet.PageSetup.Orientation = xlLandscape

"Impossible de définir la propriété Orientation de la classe PageSetup."

I saw somewhere that this properties is readonly.  But it works in VB.
I've tried that myself and it appears to work fine.  

The only thing I can suggest is you make sure you haven't made a mistake anywhere like closed the workbook or anything before trying to set the property.

Also, you might want to try reading the property value as a test that it can be accessed ok.
DanielBlaisAuthor Commented:
I have tried to read the properties and it doesn't work.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now