Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

DraftDocument PrintOut Sub. How can I print a specific sheet.

Status
Not open for further replies.

mfspini

Mechanical
Feb 29, 2008
7
This is my first post.
I have been programing diferent tools using VBA in Excel that work with SE.
Now I am trying to print a specific sheet of a draft document.
I open the draft document, detect the sheets size and orientation but I can't print out only a specific sheet.
The function I am using is:
Sub PrintOut([Printer], [NumCopies], [Orientation], [PaperSize], [Scale], [PrintToFile], [OutputFileName], [PrintRange], [Sheets], [ColorAsBlack], [Collate])
For example whith an open document:
Set objApp = GetObject(, "SolidEdge.Application")
Set objDoc = Nothing
Set objDoc = objApp.Documents.Open(CStr(Trim(celda.Value)))
lPaperSize = objDoc.ActiveSheet.SheetSetup.SheetSizeOption
lPaperOrient = 1
Call objDoc.PrintOut(Orientation:=lPaperOrient, ColorAsBlack:=True, PaperSize:=lPaperSize)
The document have 3 pages or sheets and I want to print only sheet 1 (call sheet "Sheet1") but I can't.
I have tried lots of posibilities but I can't do it.
I need some help.


 
Replies continue below

Recommended for you

Hi,

before the RpintOut use this:

objDoc.Sections.WorkingSection.Sheets.Item(" your sheet name here ").Activate

Note: the name of the sheet must be typed exactly as found on the tab.

HTH

dy
 
Hi,

I did this:

objDoc.Sections.WorkingSection.Sheets.Item("Hoja1").Activate
Call objDoc.PrintOut(Orientation:=lPaperOrient, ColorAsBlack:=True, PaperSize:=lPaperSize, Scale:=1#)

But it still printing all pages of the document.
Do you have another one?

thenks
 
Hi,

may I point out that the PrintOut method also has a PrintRange
argument which can be given as:

igPrintSelected = last active sheet
igPrintAll = all sheets
igPrintSpecified = a range of sheets (i.e 2 to 5 ...)

dy
 
Hi,
I can not make it work. Could you please give me a complete example.
Thank you very much.
MS
 
Hi,
Set oApp = GetObject(, "SolidEdge.Application")
Set oDraft = oApp.ActiveDocument
Call oDraft.Sections.WorkingSection.Sheets.Item("Connector 3 complete").Activate
Call oDraft.PrintOut(Printer:="Adobe PDF", Orientation:=vbPRORLandscape, PaperSize:=vbPRPSA3, PrintRange:=igPrintSelected)

Note: lPaperSize = objDoc.ActiveSheet.SheetSetup.SheetSizeOption
will give you SE's paper size but needed is the papersize constant for the
Printer. See also the sample Batch program within C:\...\Custom
These are standard up to at most A3

A4 = vbPRPSA4 = 9 (SE SheetSizeOption = igIsoA4Tall =28)
A3 = vbPRPSA3 = 8 (SE SheetSizeOption = igIsoA3Wide = 31)
A2 = 66 (but this may vary from printer to printer)
(SE SheetSizeOption = igIsoA2Wide = 33

dy
 
Hi,

I am very gratefull, it is working now.
Please if you need help in other topics let me know.

MS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor