OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   Saving and Printing without the Confirmation Dialogs (http://forum.oberonplace.com/showthread.php?t=6969)

beejhuff 12-05-2010 16:09

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!

shelbym 12-05-2010 17:26

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

beejhuff 13-05-2010 08:16

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

shelbym 13-05-2010 17:34

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


All times are GMT -5. The time now is 02:46.

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