Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel VBA Question
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00220436
Message ID:
00221254
Vues:
13
Try some thing like this, which gave me a print area one page wide and four pages long.
Good luck.

****************************************************
* OneByN.PRG
* Author: Thomas Molloy
* Based on a routine in SEUVFP6- Menachem Bazian et al.
* Set the print to produce a report one page wide
* This program produces an empty worksheet with a print area one
* sheet wide and four sheets long

* Add the Excel type definitions and define True and False
#INCLUDE Excel.h
#DEFINE True .T.
#DEFINE False .F.

* Here we go
* Get a reference to Excel

LOCAL loExcel, lcOldError, lnSheets, lnCounter

WAIT WINDOW "Starting Excel..." NOWAIT

lcOldError = ON("ERROR")
ON ERROR loExcel = .NULL.
loExcel = GetObject( , "Excel.Application")
ON ERROR &lcOldError

IF ISNULL(loExcel)
loExcel = CreateObject("Excel.Application")
ENDIF &&ISNULL(loExcel)

* Now we work in Excel
WITH loExcel

* Open the Workbook
.Workbooks.Add
* The next line is like SET SAFETY in Fox
.DisplayAlerts = False
* We only need one sheet
lnSheets = .Sheets.Count
FOR lnCounter = 1 TO lnSheets -1
.Sheets(lnCounter).Delete
ENDFOR &&lnCounter = 1 TO lnSheets -1
* Give the sheet a name
* At this position, it is .Sheets(1)
WITH .Sheets(1)
.Select
.Name = "TestPrintingOneSheetWide"
ENDWITH &&.Sheets(1)
** indicates VBA macro stuff commented out
* At this point I replace ActiveCell. with .ActiveCell.,
* Selection. with Selection., etc.
**Sub Macro1()
**'
**' Macro1 Macro
**' Macro recorded 5/20/1999 by Thomas Molloy
**'

**'
.Columns("A:A").Select
.Range(.Selection, .ActiveCell.SpecialCells(xlLastCell)).Select
.ActiveSheet.PageSetup.PrintArea = "$A$1:$G$87"
With .ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
.PrintArea = "$A$1:$G$87"
.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 = 360
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 4
EndWith &&.ActiveSheet.PageSetup
ENDWITH &&loExcel
**End Sub
=MessageBox("Done")
loExcel.Visible = True
Release loExcel
CLOSE ALL DATA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform