May 7, 2002 at 3:01 pm
This is the code that I am using to create an Excel file need to set the page orientation and set the "print to one page" option. Anyone have some input????
'********************************************
**************************
' Visual Basic ActiveX Script
'************************************************************************
Function Main()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("\\sqltest\brio\dsrValidation.csv", True)
a.WriteLine ("YR" & "," & "MO" & "," & "ENTDATE" & "," & "BUSUNIT" & "," & "BUSUNITGRP" & "," & "DIVISION" & "," & "REGION" &"," & "SLSPSN2" & "," & "PYFULLMO" & "," & "CYMTD" & "," & "MONTHPLAN" & "," & "PYQTR" & "," & "CYQTR" & "," & "QTRPLAN" & "," & "PYYTD" & "," & "CYYTD" & "," & "YTDPLAN" & "," & "PYTYR" & "," & "FULLYRPLAN")
a.Close
Main = DTSTaskExecResult_Success
End Function
Steve Johnson
Steve Johnson
May 7, 2002 at 4:27 pm
Try recording a macro in Excel while you do the task, then look at the generated code. I imagine you'll have to open the workbook through automation and set a property.
Andy
May 7, 2002 at 5:31 pm
This is the code that gets generated, not to sure what I need to strip out of this to get where I want to go.....
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
Steve Johnson
Steve Johnson
May 7, 2002 at 6:27 pm
Just this line should do it:
Orientation = xlLandscape
Now you just need to open the workbook via code, set for the first (only) sheet? Something close to this (off the cuff, havent tested):
dim oApp as Excel.Application
dim oBook as Excel.workbook
dim oSheet as Excel.sheet
set oapp=createobject("excel.application")
set obook=oapp....open? cant remember
Once you have the book, then you can reference the sheets collection.
Andy
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply