When setting a class attribute as a property in Enterprise Architect (Property checkbox in the attribute's window), is there a way to tag the getter as a query (IsQuery checkbox in the method's window advanced tab) by default? It's not done by default and thus I have to do it manually for every property getter.
I don't think there's an option to set for this, but you might try the Template Package.
This special package is used to serve as a template for all new elements, so it might set the isQuery property as well.
If that doesn't work you can make a little script as workaround to set it for every getter.
The property EA.Method.IsQuery is available in the API.
So a VBScript script to update this could be something like
option explicit
!INC Local Scripts.EAConstants-VBScript
'
' Script Name: Set IsQuery Getter
' Author: Geert Bellekens
' Purpose: sets the IsQuery property to true for all operations in the selected package with stereotype "property get"
' Date: 2016-01-22
'
sub main
dim selectedPackage as EA.Package
set selectedPackage = Repository.GetTreeSelectedPackage()
dim element as EA.Element
dim operation as EA.Method
for each element in selectedPackage.Elements
for each operation in element.Methods
if operation.Stereotype = "property get" then
operation.IsQuery = true
operation.Update
end if
next
next
end sub
main
Related
I want to change the variant name of smartFilterBar from 'standard'(default variant name) to 'custom'(some custom name which shows instead of 'standard' ). when app initialise at first .
Why should you do this? The SmartFilterBar control including its variant management allows the user to define any variant and set the flag "default" to it which will result in this custom variant being loaded on init. If you add some logic like you suggest, you would invalidate this feature and your users will be confused why the variant that he/she selected is not taken.
If you are using SmartVariantManagement, there is a property called 'standardItemText', using which you can set any new name.
Is there a way I can quickly mimic all the properties of a form into for a new form one without directly copying the object (Ctrl-C&V, etc)?
Edit: Looking to copy into an entirely different Access Database.
Open each form in design view, set them equal to an object variable, and then set the properties of the source form equal to the proeprties of the destination form. Use a funciton like this in a public module:
Public Sub UpdateForm(SourceForm as string, DestinationForm as string)
dim frm1 as new form
dim frm2 as new form
set frm1 = forms(SourceForm)
set frm2 = forms(DestinationForm}
'* List the properties you want to copy here:
With form2
.RecordSource = frm1.RecordSource
.Caption = frm1.Caption
.DataEntry = frm1.DataEntry
'* And so on for each property
End With
docmd.save acform, DestinationForm
End Sub
If it's not a one-off project, I'd include some code to check and open the forms if they weren't already open.
File > Options > Object Designers > Form/Report Design View > Form template.
Set the form template to the name of an existing form and that will be used for all new forms.
You can copy a form object using VBA in a slightly more simple way than what DataWriter suggests.
You can use the following statement in the immediate window:
DoCmd.TransferDatabase acExport, "Microsoft Access", CurrentProject.FullName, acForm, "Form1", "Form1_Copy"
Where "Form1" is the name of the source form, and "Form1_Copy" is the name of the destination form.
I'm trying to get value from textfield on the form.
sub Test(oEv)
oForm = oEv.Source.Model.Parent
textBox = oForm.getByName("Description")
MsgBox textBox.Text
end sub
There is an Exception: "Type: com.sun.star.container.NoSuchElementException" on the line "textBox = oForm.getByName". I have a text field with the name "Description" on the same form, where is the button I press to run this macro. What is wrong here?
Check that the name is the same case, not description.
Also, use the Form Navigator to determine whether the control is under the form in the hierarchy.
Have you tried using an introspection tool such as MRI or XrayTool to view the properties of oForm? With the tool, expand the form to see if it contains the Description control.
Often in Base, it is better to deal with the form as a recordset rather than reading the controls. Here is some sample code:
Sub ButtonClickHandler(oEvent as Object)
'com.sun.star.comp.forms.ODatabaseForm
oForm = oEvent.Source.Model.Parent
lDescriptionCol = oForm.findColumn("DESCRIPTION") ' from underlying query or table
Print(oForm.getString(lDescriptionCol))
BasicLibraries.LoadLibrary("XrayTool")
xray(oForm)
End Sub
For more ideas, see https://forum.openoffice.org/en/forum/viewtopic.php?f=39&t=38725.
My question is : how to use the view identifier as parameter?
Code example:
Dim DrwDocument As DrawingDocument
Set DrwDocument = CATIA.ActiveDocument
Dim iParameter As Parameter
Set iParameter = DrwDocument.Parameters.Item("Drawing\Sheet.1\ViewMakeUp.1\Scale")
MyText.InsertVariable 0, 0, iParameter
but how can i access to the view identifier, and use it as parameter?
thank you!
Ok, do do this you must first create a parameter in the DrawingDocument object.
So you would have something like this added to your current code:
Dim IndetifierParam as Parameter
Set IdentifierParam = MyDrawingDocument.Parameters.CreateString("ViewIdentifier", "A")
MyText.Text = "View ID: "'note: there are two spaces from last character to end of the quote
MyText.InsertVariable Len(MyText.Text),0,IdentifierParam 'First parameter is insert position, second parameter is how many characters to overwrite, third is the parameter.
Now, in the drawing tree on the left you will see a Parameter Set with your new String Parameter. Double click the parameter and edit it...The drawing test will automatically update the drawing text with the changed parameter value. ALSO, as an added benefit, it's much easier in a VBA script to modify a parameter than the drawing text.
How to update or change this new Parameter:
IdentifierParam.ValuateFromString "A" 'add a string or variable here
Lastly, an extra tip, Go to Tools -> Options and click Parameters and Measure from the tree and on the First tab "Knowledge" check "With Value" and "With Formula" They are the first two checkboxes.
I would like to do something like add a nice-to-Excel-functions Name property to the WorkBook class. Is there a good way to do this?
More detailed problem: In VBA you can assign a formula to a range in an Excel worksheet. I want to do so, and I want my formula to refer to a second workbook, which is an object called wb in my code. I then use wb.Name in assigning a formula to a range.
The problem arises when wb.Name has a single-quote in it. Then you wind up with something like this:
=MONTH('[Ryan's WB]Sheet1'A1)
in the spreadsheet, which fails because the single-quote in the workbook name matches to the first single-quote.
What I would like is a FunName property for the WorkBook class that replaces all single-quotes in the Name property with two single-quotes and returns that. Then the above formula would properly wind up looking like
=MONTH('[Ryan''s WB]Sheet1'A1)
You don't need to make a separate class to extend the workbook class. You can add properties to the existing ThisWorkbook class module, like this:
Public Property Get FunName() As String
FunName = Replace(Me.Name, "'", "''")
End Property
Then you call ThisWorkbook.FunName to get your cleaned up name. However, this code has to exist in the workbook at hand. If you want it to work on any workbook, your function is the way to go.
Just do a replace to double up the single quotes
WorksheetName = Replace(WB.Name, "'", "''")
What you need is a Class which extends the Workbook object. Insert a class module, then try the following code
Dim WithEvents WB As Workbook
Public Sub SetWB(W As Workbook)
Set WB = W
End Sub
Public Property Get FunName() As String
FunName = Replace(WB.Name, "'", "''")
End Property
Private Sub WB_SheetCalculate(ByVal Sh As Object)
'this runs when WB calculates
End Sub
'use it like this
Dim WB As New wbClass
WB.SetWB ActiveWorkbook
CleanedName = WB.FunName
Note that as a bonus, I've put WithEvents in the line that Dims WB at the top of the class. This allows you to trap all the events that happen to WB, and I included the Calculate event as a demo above. If you are in the class code and click the objects dropdown at top left of the code pane, you'll see the WB object, and if you click this, the right hand list box will give you all the events to choose from.
The final answer appears to be that the WorkBook class can be extended to include a name property that is nice to Excel formulas. This can be done using the method provided by dbb. However, since VBA does not support inheritance, objects of the extended class will have only the properties you define for them.
Therefore, it really makes more sense to just use a function. Here's what I'm going to use:
Function FormulaWorkName(ByVal aName As String) As String
FormulaWorkName = Replace(aName, "'", "''")
End Function
Which I will apply to both worksheet names and workbook names.