×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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.

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

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

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

(OP)
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

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

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

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

(OP)
Hi,
I can not make it work. Could you please give me a complete example.
Thank you very much.
MS

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

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

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

(OP)
Hi,

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

MS

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

Hi,
you're welcome. To obtain the papersize constants for formats
that are not enumerated you may use the program PaperSizeConstants
(see link below)

dy

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources