Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2003
    Posts
    106

    Unanswered: Editing Excel from Access VB

    Hi all

    Can anyone squash this one for me?

    I have opened an Excel spreadsheet from a VBA module and formatted the text exactly how i want to.

    I have set the margins, print options, page size, header, footer etc.

    There are two things that i can't seem to crack.

    I need the page setup page orientation to be landscape (Access doesn't like 'xlLandscape') and i need to put borders around a range of cells (access doesn't like xlBorderTop, xlBorderBottom etc.)

    I have created the Excel objext as 'Excel.Application'

    Excel.Application.ActiveSheet.PageSetup.PrintTitle Rows "$1:$4"
    Excel.Application.Range("A1:J4").Borders ?.....
    Excel.Application.ActiveSheet.PageSetup.Orientatio n = ?......

    Any ideas?

    Thanks

    Dan

  2. #2
    Join Date
    Jan 2003
    Location
    Rockville, MD
    Posts
    179
    Hi Dan,

    Try this for the borders. I don't remember which border (7-10) is top, left, bottom, and right, or what the values for linestyle and weight are though.
    Code:
       Excel.Application.ActiveSheet.Range("A1:J4").Borders(7).LineStyle = 1
       Excel.Application.ActiveSheet.Range("A1:J4").Borders(7).Weight = -4138
       Excel.Application.ActiveSheet.Range("A1:J4").Borders(8).LineStyle = 1
       Excel.Application.ActiveSheet.Range("A1:J4").Borders(8).Weight = -4138
       Excel.Application.ActiveSheet.Range("A1:J4").Borders(9).LineStyle = 1
       Excel.Application.ActiveSheet.Range("A1:J4").Borders(9).Weight = -4138
       Excel.Application.ActiveSheet.Range("A1:J4").Borders(10).LineStyle = 1
       Excel.Application.ActiveSheet.Range("A1:J4").Borders(10).Weight = -4138
    For landscape, try orientation = 2
    Code:
       Excel.Application.ActiveSheet.PageSetup.Orientation = 2
    Hope that helps,
    JT

  3. #3
    Join Date
    Aug 2003
    Posts
    106

    Solution!

    That's great!

    Thanks

    Dan

  4. #4
    Join Date
    Oct 2002
    Location
    Argentina
    Posts
    72
    Just 1 for portrait and 2 for landscape

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •