This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

need to call another macro

i want to use 2 macros, save as in lower version and convert to curve on 1 click is that possible?

Parents
  • I am not sure I correctly understand what you mean...

    So, saying that you work in Corel 2022 and you firstly need to save the active workbook in X6 version and secondly do whatever related to conversion to curve, would it be a correct understanding? If so, it is simple to save in a previous version...

    Then, „convert to curve” is a foggy request. I mean, what do you want converting to curve? You cannot convert to curve a document...

    You need to specify. Something as „active shape”, all shapes from the active layer, all shapes from the active page, shapes being of a specific type (cdrRectangle, for instance) etc.. So, what do you want converting to curve?

    Then, why are you talking about „using 2 macros”? Is this a real situation requirement, or you only want understanding how you can call a different function? Even so, would the second function being in the same workbook or in a different one? Would it be called with arguments? Should it return something? If not, why are you talking about a function and not a Sub?

    Anyhow, this would be a code sample showing how to save As from 2022 in X6:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    Sub Save_AS_Lower_version()
        Dim SOpts As StructSaveAsOptions
        Set SOpts = CreateStructSaveAsOptions
        With SOpts
            .EmbedVBAProject = False 'True
            .Filter = cdrCDR
            .IncludeCMXData = False
            .Range = cdrAllPages 'cdrCurrentPage
            .EmbedICCProfile = True
            .Version = cdrVersion16
            .KeepAppearance = True
        End With
        ActiveDocument.SaveAs "C:\YourFolderName\Saved as X6.cdr", SOpts
        'it overwrites existing, if the case...
    End Sub
    

    For converting as curves:

    1
    2
    3
    4
    5
    6
    7
    Sub testConvertToCurves()
      Dim sh As Shape, shR As Shape, actL As ShapeRange
      'Set sh = ActiveShape: sh.ConvertToCurves 'it works
      'Set shR = ActiveSelection: shR.ConvertToCurves   'it works
      'ActiveSelection.ConvertToCurves 'also works
      Set actL = ActiveLayer.Shapes.All: actL.ConvertToCurves 'for all active layer shapes
    End Sub
    

    Related to calling a Sub from another GSM, place the next testing code in the GMS file where the first macro is (or place the single code line in the first macro. It will call a macro from `GlobalMacros`:

    1
    2
    3
    Sub callMacroFromGlobalMacros()
      Application.GMSManager.RunMacro "GlobalMacros", "Tests.MacroToBeCalled"
    End Sub
    

    And the macro to be called (from GlobalMacros):

    1
    2
    3
    4
    Sub MacroToBeCalled()
      MsgBox "I was called from another document/GMS...", vbCritical, "Calling from another document/GMS"
      'ActiveSelection.ConvertToCurves
    End Sub
    
Reply Children
No Data