How to search in Enterprise Architect from an Excel worksheet? - jscript

I'm a trainee and my boss asked me to make a script that searches for packages in Enterprise Architect from a name. The base is in Excel and count all the use-cases, the count I already did, but the search I could not get yet.
*edit: the count im already made, but i need a search metod, get all names from a excel file and searchs this names on Ea

You can do this with the ActiveX Object functionality with Jscript in EA, basicaly you can open the excel sheet directly from your script and read the data
ActiveX Object Jscript Reference
ActiveXObject in Sparx EA
VBScript, JScript and Javascript can each create and work with ActiveX
/ COM objects. This can help you to work with external libraries, or
to interact with other applications external to Enterprise Architect.
For example, the Scripting.FileSystemObject Class can be used to read
and write files on the local machine. The syntax for creating a new
object varies slightly for each language, as illustrated by these
examples:
VBScript:
set fsObject = CreateObject("Scripting.FileSystemObject")
JScript:
fsObject = new ActiveXObject("Scripting.FileSystemObject");
Javascript:
fsObject = new COMObject("Scripting.FileSystemObject");
Note: from my personal experience, this doesn't work with a JavaScript script, use Jscript or VBscript

Related

Integrate VBA - SAP with Outlook [duplicate]

Is there a way to view the properties on SAP GUI objects?
Like this:
But for SAP objects like the following ones:
Set SAPGuiAuto = GetObject("SAPGUI")
Set App = SAPGuiAuto.GetScriptingEngine
Set Connection = App.Children(0)
Set SAPSession = Connection.Children(0)
I ask this after reading the last part of the answer to this post: VBA general way for pulling data out of SAP
If however you want to use early binding so that your VBA editor might
show the properties and methods of the objects you are using, you need
to add a reference to sapfewse.ocx in the SAP GUI installation folder.
This is something so badly advertise by the SAP team, they should definitely do a better job there.
Basically you first of all need to add a reference to the SAP object model, the libraries that VBA will understand. Don't know how familiar are you with there references to object models. Basically, on your VBA Editor, click Tools, then References, then Browse, and find this file: "C:\Program Files\SAP\FrontEnd\SAPgui\sapfewse.ocx" (or possibly "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\sapfewse.ocx").
Now you'll be able to browse it on the Object Explorer (press F2 in the VBE), and declare the types.
You need now to familiarise yourself with the Types of this library. Some hints, they all start with Gui, like, GuiSession, GuiApplication, GuiConnection, GuiBlabla... Names are pretty explicit and intuitive.
To add on to what #Nelson_Vides has said. As he said, you will need to reference the sapfewse.ocx file, and you can view the class objects by pressing F2.
However, the IntelliSense will only be visible once you define an object from the SAP class library.
Dim userArea As GuiUserArea ' <-- For example
Now, whenever the object is used the IntelliSense will show up.
Best of luck and happy scripting!
SAP also provides documentation on their GUI objects:

Error using application.filedialog to open a file VBA7.0

I have recently installed visio 2010. it has VBA 7.0.
I am trying to write a code to open a file dialog, choose an excel file and open it.
I used this code
Set fd = Application.FileDialog(msoFileDialogFilePicker)
but i get the following error:
Run-time error '438':
Object doesn't support this property or method
i already have the Microsoft Office 14. Object Library as reference.
Do you have an idea? what i should do?
If you use this code in Visio
Set fd = Application.FileDialog(msoFileDialogFilePicker)
the word Application refers to Visio and as you can see in Object Browser, Visio.Application class has no such method as FileDialog. Access and Excel applications have it, but not Visio.
In order to use it in Visio you need to add reference to either Microsoft Excel Object Library or Microsoft Access Object Library. Then you need to use the code below to create an instance of FileDialog (select a proper version depending on what reference did you add to your project - Excel or Access)
'If you have reference to Microsoft Excel Object Library
Set fd = Excel.Application.FileDialog(msoFileDialogFilePicker)
or
'If you have reference to Microsoft Access Object Library
Set fd = Access.Application.FileDialog(msoFileDialogFilePicker)
Like explained by #mielk, Visio does not have the Application.FileDialog. You could use the method of Excel (in this case you'll have to have Excel installed, and started to invoke its methods) or use pure WinAPI from VBA (i.e. GetOpenFileName function). This option is explained here for example:
http://visguy.com/vgforum/index.php?topic=738.0

Creating a C# program that works with an existing Excel Workbook

firstly I'm not even sure if its even possible so i thought id ask
all research that i have done haven't given me the answers and info I need.
I need to create a VS Win forms program (using visual studio 2012) that interacts with a DB & AN EXCEL 2010 WORKBOOK?
can it be reasonably done?
the specifics are these
the excel 2010 workbook already exists and comprises 35 sheets/pages, BUT NOT ALL PAGES NEED TO BE USED IN THE PROGRAM only 12 do. it is a workbook for project management
the program works with button click events, that when pressed would open a specific page/sheet of the workbook. the user would then be able to fill in fields etc and save it
ideally also print it(Specific page) (from program and not excel directly) and obviously access it and amend or add to it from the Program time and time again
the workbook is a master workbook so every time a new project is created, the program would need to generate a new "instance" of the master workbook (the 12 pages)
each project and the "instance" of the workbook would need to be saved separately on the Hard Drive
this is/would be a client side stand alone application running on a laptop
is this possible? or highly complex?
and if so what are the relevant classes that would need to be imported into the project
or is it better/possible? to take the relevant pages ad make a new workbook inside of visual studio office node and make instances of it ??
at no point at all does data in the DB or Excel workbook need to be transferred to one another. they run separately but are part of the one program
any and all help would be appreciated
This is not a complex project, visual studio supports Microsoft Excel 12.0 Object Library. You can import the library and start using the events built in. It works great with excel. I have created numerous projects just like the one you've mentioned and had no problems so far.
Try this link

Programatically import Microsoft.Office.Interop.Excel namespace in VBA project

I'm trying to programatically import Microsoft.Office.Interop.Excel namespace into my vba project. I found this site
that displays how to import it manually, but I'm giving this project that I've been working on to people that won't know how to import it. Can anybody please help?
I assume from your question that your VBA code uses a reference to the Microsoft Excel 12.0 (or other version) library - and that your user gets an error as the reference cannot be found. In this case, you have two options:
Instead of referring to the v12 library, refer to an older library, e.g. from Excel 2003. To do so, search the net for this library and install it - or simply "relink" your file in an Office 2003 installation before shipping
Use late binding instead of early binding. In this case, you do not add a reference to the Excel library at all. Instead, you declare your objects as type Object(instead of Excel.Workbook, Excel.Application, etc.). To create a new object, instead of using Set objExcelApp = New Excel.Application, you must now use CreateObject (for new objects) or GetObject (for existing objects, e.g. an existing, running application): Set objExcelApp = CreateObject("Excel.Application"). Any later code will continue to work as usual (though it might be a tiny bit slower due to the late binding).
For further reading, check this answer.

Excel 2007 VBA FileSearch missing

Someting happened with FileSearch object in Excel 2007.
In documentation it is said that FileSearch is hiden.
Does it mean that there is no way to search for files using Excel VBA anymore?
You can still search using the Dir function - lots of examples on the web if you search for 'excel 2007 vba filesearch', for example this post.
I would add a reference to the Microsoft Scripting Runtime library. That gives you access to the FileSystemObject, which lets you pretty easily test for the existence of a file and/or iterate through directories, doing your own search.
If you want to search on custom document properties, there's currently no way to do it. You have to narrow the search with Dir and open each one individually.
As Steve said you can use the FSO object to search for files using a given root path and filter expression. There is good documentation available on fitlering by extension (remember to include the extensions you want or filter by .xls) and using the objects in the FSO object model.
For an explanation (by msft) on the depreciation of FileSearch method. see - http://support.microsoft.com/kb/920229
For a basic pattern to using the FSO for searching a set of directories recursively with the FSO see -
http://support.microsoft.com/kb/185601
You can still use the
Application.GetOpenFilename
if you want to get back the path to a workbook.

Resources