OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   Macros/Add-ons (http://forum.oberonplace.com/forumdisplay.php?f=21)
-   -   ExportBitmap with not rewrite file (http://forum.oberonplace.com/showthread.php?t=24772)

FaneDuru 20-11-2016 08:02

ExportBitmap with not rewrite file
 
Is it a way in case of ExportBitmap automation to receive a warning in case of a file with the same name already exists?

I mean for the next piece of code is it a way to stop export in case that a file with the same name already exists in the export folder...
Code:

Set Filter = d.ExportBitmap(strFile, cdrJPEG, cdrCurrentPage, _
    cdrRGBColorImage, 1000, 1000, 300, 300)
  With Filter
    .Compression = 80
    .Optimized = True
    .Smoothing = 10
    .SubFormat = 1
    .Progressive = False
    .Finish 'is there a way to stop this part for the same file name in export location folder...
  End With


shark 21-11-2016 00:38

you can use the standard function FileAttr to see whether a file exists:

Code:

If CorelScriptTools.FileAttr(strFile) <> 0 Then
    If MsgBox("Rewrite " + strFile + " ?", vbYesNo + vbQuestion, _
            "File exist") = vbNo Then
        ' set new name for strFile
    else
        ' rewrite file
    end if
end if

'your code...
Set Filter = d.ExportBitmap(strFile, cdrJPEG, cdrCurrentPage, _
      cdrRGBColorImage, 1000, 1000, 300, 300)


FaneDuru 21-11-2016 14:33

Thanks!
I found a similar workaround:
Code:

Inceput:
'Code using GetFileBox to select the name but seeing the pictures there, returning strFile...

Director = Left(strFile, InStrRev(strFile, "\"))
NumeDublu = Right(strFile, Len(strFile) - InStrRev(strFile, "\"))
 
  Fisier = Dir$(Director)
  Do While Len(Fisier) <> 0
    Fisier = Dir$: If Fisier = NumeDublu Then GoTo Nasol
  Loop
  Filter.Finish

  'Some other code here...

  GoTo Sfarsit
Nasol:
  Dim Rasp As VbMsgBoxResult
  Rasp = MsgBox("The file named """ & NumeDublu & """ already exists in the export location." & vbCrLf & _
                "  Would you like to rewrite it?" & vbCrLf & vbCrLf & _
                "  If yes, please choose ""Yes""..." & vbCrLf & _
                "  For renaming choose ""Cancel"".", vbYesNoCancel, "Existing name")
        If Rasp = vbYes Then
            Filter.Finish

            'some code here...

            GoTo Sfarsit
        End If
        If Rasp = vbCancel Then GoTo Inceput
Sfarsit:



All times are GMT -5. The time now is 00:48.

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