General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › Read Only Mode – Xmetal 5.5
-
vithaljoshi July 1, 2009 at 6:18 pm
Read Only Mode – Xmetal 5.5
July 1, 2009 at 6:18 pmParticipants 2Replies 3Last Activity 12 years, 12 months agoHi,
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 IfThe 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.
Derek Read July 2, 2009 at 4:01 pm
Reply to: Read Only Mode – Xmetal 5.5
July 2, 2009 at 4:01 pmCan 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).
vithaljoshi July 2, 2009 at 4:40 pm
Reply to: Read Only Mode – Xmetal 5.5
July 2, 2009 at 4:40 pmThis 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 = FalseDerek Read July 2, 2009 at 6:35 pm
Reply to: Read Only Mode – Xmetal 5.5
July 2, 2009 at 6:35 pmActiveDocument.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.
-
AuthorPosts
- You must be logged in to reply to this topic.