OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 15-10-2004, 07:00
olympiatr
Guest
 
Posts: n/a
Default save filename without extension and prn automation error

my first problem is about saving file by it's name without it's extension. it always writin ".cdr" end of it. can i do this over corel vba? and second problem is corel givin error code when you want to print out documents (write to file ".prn") automation. why? Alex, can you help us about this problem. you can see the two problem code below;
(by the way my technical info: xp professional, corel draw 12, p4 2.8 512 mb machine)

'when i want to work around more documents by this code it givin error

For Each d In Documents
Dim dosyaYolu As String
Dim fname As String
dosyaYolu = TextBox1.Text
fname = d.FileName
If Right$(dosyaYolu, 1) <> "\" Then dosyaYolu = dosyaYolu & "\"
With ActiveDocument.PrintSettings: .SelectPrinter "Xerox DocuTech 6135"
.SetCustomPaperSize 12.6, 17.7, prnPaperPortrait '.PaperWidth = 12.6: .PaperHeight = 17.7
.PrintToFile = True: .FileMode = prnSingleFile
.FileName = dosyaYolu & fname & ".prn" 'here is the name problem
.ForMac = False: .UsePPD = False
With .PostScript: .JPEGCompression = True: .JPEGQuality = 151: End With
.Options.BitmapColorMode = prnBitmapGrayscale
End With: ActiveDocument.PrintOut

Next d

thanx for all
Reply With Quote
  #2  
Old 15-10-2004, 10:33
olympiatr
Guest
 
Posts: n/a
Default sorry found first problem's answer

luckly i found the firs problem's answer here;

http://www.oberonplace.com/forum/viewtopic.php?t=173

i'm lookin forward for second problem
Reply With Quote
  #3  
Old 16-10-2004, 14:46
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: sorry found first problem's answer

Olympia,

I'm not sure what is wrong with your code. It could be that wither the folder is not correct or the document is not saved and it's file name is empty. Also, you are looping through open documents but still print the current (active) document only.

Finally, you are setting a custom paper size for the printer and I'm assuming that you want to set the page size to 12.6" x 17.7", however printer paper size is always reported in millimeters, so you need to set the paper to 320 mm x 450 mm instead.

Here is a revised code which seems to work on my side:

Code:
Sub PrintToFile()
    Dim d As Document
    Dim Folder As String
    Dim fname As String
    Dim n As Long
    
    Folder = "C:\Temp\"
    If Right$(Folder, 1) <> "\" Then Folder = Folder & "\"
    
    For Each d In Documents
        fname = d.FileName
        If fname = "" Then fname = d.Title
        n = InStrRev(fname, ".")
        If n <> 0 Then fname = Left$(fname, n)
        With d.PrintSettings
            .SelectPrinter "Xerox DocuTech 6135"
            .SetCustomPaperSize 320, 450, prnPaperPortrait
            .PrintToFile = True
            .FileMode = prnSingleFile
            .FileName = Folder & fname & ".prn"
            .ForMac = False
            .UsePPD = False
            With .PostScript
                .JPEGCompression = True
                .JPEGQuality = 151
            End With
            .Options.BitmapColorMode = prnBitmapGrayscale
        End With
        d.PrintOut
    Next d
End Sub
Reply With Quote
  #4  
Old 20-10-2004, 03:16
olympiatr
Guest
 
Posts: n/a
Default thanx very much

it is great Alex, thank u again. (hope not borin my silly questions, cause i am nearly new one about vba
Reply With Quote
  #5  
Old 20-10-2004, 04:59
olympiatr
Guest
 
Posts: n/a
Default one more thing!!!

is it possible to add code for "fit to page" to this prn?? :idea:
Reply With Quote
  #6  
Old 20-10-2004, 07:17
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: one more thing!!!

Quote:
Originally Posted by olympiatr
is it possible to add code for "fit to page" to this prn?? :idea:
No, unfortunately the options available on Layout tab of Print dialog are not yet available to VBA...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 07:10.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com