General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Read Only Mode – Xmetal 5.5

  • vithaljoshi

    Read Only Mode – Xmetal 5.5

    Participants 2
    Replies 3
    Last Activity 13 years, 3 months ago

    Hi,

    I am having problems in setting the read only mode in XMetal 5.5

    Following is the piece of code that i am using:

        Dim xmlReadMode As Object
        Set xmlReadMode = XMetaL.ActiveDocument.Range
        xmlReadMode.MoveToDocumentStart
        xmlReadMode.Select
       
        If readOnlyAttrib Then
          xmlReadMode.ReadOnlyContainer = True
          xmlDoc.Title = xmlDoc.Title & ” (Read Only)”
        Else
          xmlReadMode.ReadOnlyContainer = False
        End If

    The system doesnt seem to accept the line Set xmlReadMode = XMetaL.ActiveDocument.Range , is there anything wrong with this , it works fine with the previous versions of XMetal though.

    Reply

    Derek Read

    Reply to: Read Only Mode – Xmetal 5.5

    Can you say if this is XMetaL Author or XMAX?

    Where does this script live? I suspect it is not in an MCR file and part of some application that contains XMAX?

    I'm asking because I'm wondering why you are including “XMetaL” at the beginning of XMetaL.ActiveDocument.Range. If this is XMAX then that sort of makes sense, but we're missing the code that defines what that is and the issue might be there.

    The second part that starts with “readOnlyAttrib” also does not have any context. We don't know what readOnlyAttrib or xmlDoc are (if this is important to your issue).

    Reply

    vithaljoshi

    Reply to: Read Only Mode – Xmetal 5.5

    This is an XMetal Author. The script is in VB.

    Yes don't bother about the other things.

    Just wanted to know if
    Set xmlReadMode = XMetaL.ActiveDocument.Range
    xmlReadMode.ReadOnlyContainer = True
    is a valid statement.

    I think there is one more way to set the read only attribute:
    ActiveDocument.Range.Writable = False

    Reply

    Derek Read

    Reply to: Read Only Mode – Xmetal 5.5

    ActiveDocument.Range is valid and what you have should work I think, as long as “XMetaL” is a variable (object) that represents XMetaL Author instantiated as a COM object.

    Here's the simplest fully functional script that does what you are asking for. For readability I've renamed your “xmlReadMode” to “rng” because that is more descriptive of what that object actually is.

    Save the following into a *.vbs file and run:

    [code]Set XMetaL = CreateObject (“XMetaL.Application”)
    Set rng = XMetaL.ActiveDocument.Range
    'toggle ReadOnlyContainer for current selection
    if (rng.ReadOnlyContainer = true) then
    rng.ReadOnlyContainer = false
    else
    rng.ReadOnlyContainer = true
    end if
    msgbox(rng.ReadOnlyContainer)
    Set XMetaL = nothing[/code]

    Note that you may need to alter the variable declarations if you are not working with VBScript in your actual solution.

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support