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 12-05-2010, 16:09
beejhuff
Guest
 
Posts: n/a
Default Saving and Printing without the Confirmation Dialogs

Good Day! I've got a couple of VBA routines written for X5 that save a .cdr file, then send the file to be printed.

The problem I'm running into is that whenever I run these commands, the user is prompted with a dialog window, even though I have used the appropriate Structs to set the options.

I need to save and print the file and also suppress the confirmation dialog, so that it does not prompt the user at all. Any ideas on how to proceed? Here's what I have so far to save the file:

Code:
    ' If we've been asked to Save this document on this call
    If (Save) Then
        Set doc = ActiveDocument
        Dim opt As New StructSaveAsOptions
        ' Create a unique file name with Time/Date Stamp and .CDR Extension
        FileName = DocumentPath & Format(Now, "d-mmm-yyyy-hh-mm-ss") & ".cdr"
        ' Set Options
        opt.EmbedICCProfile = True
        opt.EmbedVBAProject = False
        opt.Filter = cdrCDR
        opt.IncludeCMXData = True
        opt.Overwrite = True
        opt.Range = cdrAllPages
        opt.Version = cdrCurrentVersion
        ' Save File
        doc.SaveAs FileName, opt
    End If
I've checked the object model for the Document.SaveAs StructSaveAsOptions object and it doesn't appear to have any such parameter. I know I can't be the only person who needs to do silent saves / prints so has anyone else come across this same issue?

Thanks in advance!
Reply With Quote
  #2  
Old 12-05-2010, 17:26
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Dialog

You get the save dialog because "DocumentPath" is empty and therefore it does not know were to save. Change DocumentPath to doc.FilePath and it should work without prompting you.

Also new to X5 is the Document.SaveAsCopy, this way the document keeps its original name. Very handy.

-Shelby

Last edited by shelbym; 12-05-2010 at 17:29. Reason: added SaveAsCopy
Reply With Quote
  #3  
Old 13-05-2010, 08:16
beejhuff
Guest
 
Posts: n/a
Default Suppressing the Save Dialog

Shelby, thank you for taking the time to respond. I'm going to test with your suggestion, but I am actually setting that variable in a different section of code, here's my full listing:

Code:
    
    ' These assignments and their corresponding declarations occur in another module (they're global in scope)
    AppPath = "C:\Wizard"       ' Directory containing Wizard support files
    CDRPath = "CDR"             ' Directory to archive saved Corel Draw Files
    TicketPath = "Tickets"      ' Directory to archive saved Claims Tickets

    '...After assigning these variables, I test and confirm that I DO have a value stored for the full path in the concatenated location I'm using below
.
.
.

Public Sub CreateSign(ByVal SignNumber As Integer, ByVal Name As String, ByVal ID As String, ByVal NameWidth As Double, ByVal NameHeight As Double, ByVal NameLeftPos As Double, ByVal NameBottomPos As Double, Optional ByVal Save As Boolean)
On Error GoTo ERR_CreateSign

    Dim sh As Shape
    Dim doc As Document
    Dim FileName As String
         
    ' Select Text Name Shape
    If SignNumber = 1 Then
        ActivePage.Shapes.FindShape(Query:="@name = 'Name1'").CreateSelection
    ElseIf SignNumber = 2 Then
        ActivePage.Shapes.FindShape(Query:="@name = 'Name2'").CreateSelection
    End If
    
    Set sh = ActiveShape                    ' Set my Shape Object to the currently selected active shape
    
    ' Update it's text contents
    sh.Text.Story = Name
    
    ActiveDocument.Unit = cdrInch
    ActiveDocument.ReferencePoint = cdrBottomLeft
    
    ' Resize to NameWidth x NameHeight
    sh.SizeWidth = NameWidth
    sh.SizeHeight = NameHeight
    
    ' Left - Align Text Field to NameLeftMargin
    sh.LeftX = NameLeftPos
    sh.BottomY = NameBottomPos
      
    ' Deselect the current shape
    
    ' Select the Text ID Shape
    If SignNumber = 1 Then
        ActivePage.Shapes.FindShape(Query:="@name = 'SignID1'").CreateSelection
    ElseIf SignNumber = 2 Then
        ActivePage.Shapes.FindShape(Query:="@name = 'SignID2'").CreateSelection
    End If
    
    ' Set my Shape Object to the currently selected active shape
    Set sh = ActiveShape
    
    ' Update it's text contents
    sh.Text.Story = ID

    ' If we've been asked to Save this document on this call
    If (Save) Then
        Dim opt As New StructSaveAsOptions
        ' Create a unique file name with Time/Date Stamp and .CDR Extension
        FileName = AppPath & "\" & CDRPath & "\" & Format(Now, "d-mmm-yyyy-hh-mm-ss") & ".cdr"
        ' Set Options
        opt.EmbedICCProfile = True
        opt.EmbedVBAProject = False
        opt.Filter = cdrCDR
        opt.IncludeCMXData = True
        opt.Overwrite = True
        opt.Range = cdrAllPages
        opt.Version = cdrCurrentVersion
        ' Save File
        ActiveDocument.SaveAs FileName, opt
    End If
    
Exit_CreateSign:
    Exit Sub

ERR_CreateSign:
    MsgBox Err.Description
    Resume Exit_CreateSign

End Sub
Have you tried this yourself on X5? I'm concerned that the functional behavior may have been modified in this latest release compared to previous releases (this doesn't appear to happen in X3 and below), although that is not documented in the manuals.

I am new to X5 so I'm hoping to get some independent confirmation.

Thanks,

BJ Hoffpauir
Reply With Quote
  #4  
Old 13-05-2010, 17:34
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default SaveAs

Yes I did test it with X5, and as long as the Path does exist I am not prompted with a dialog the file saves properly in the background.

-Shelby
Reply With Quote
Reply

Tags
coreldraw 15, coreldraw x5, document.print, document.saveas, vba


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help with open/save dialogs StianO CorelDRAW/Corel DESIGNER VBA 5 14-05-2009 11:10
Saving Icons knowbodynow CorelDRAW/Corel DESIGNER VBA 9 02-04-2007 20:23
X3 Workspace - Not Saving dungbtl General 3 11-06-2006 04:55
Making different palette colors to appear in dockers/dialogs/dropdowns Alex FAQ 1 06-05-2005 17:39
saving time for machine printing bumblebee CorelDRAW/Corel DESIGNER VBA 0 24-10-2004 10:09


All times are GMT -5. The time now is 19:41.


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