VBA to create Mapinfo table & points - vba

not very good at VBA, just in the basics so got stuck at below idea.
I want a VBA to create a MapInfo Tab file and points with Legend from a table in excel with given coordinates and legend based on another column.
searched a lot online, but couldn't find more than the below.
CreateObject("MapInfo.Application")
Please guide me to accomplish this.
Thanks

There are two ways of doing this.
First option is to open MapInfo application (with CreateObject("MapInfo.Application")) and create TAB file there. However, this would be basically to write an MapBasic program, VBA would be only used to start MapInfo.
The second options is to create a MIF/MID file. These are two plain text files which can be imported into MapInfo. At this page Pitney Bowes states "We do publish the MapInfo Interchange Format (MIF\MID) files in our documentation", however you find it in Chapter 13 at normal MapInfo User Guide.
I would recommend the second option. Creating two plain text files in VBA should be feasible. A good starting point would be to create a TAB file manually and export this TAB file as MIF/MID, then you have a valid example file.

Related

How can I replace one or multiple lines in the code editor with a WebView, File Preview or an Image?

I'm trying to develop an extension that needs to render text, images and the preview of an external file in the code as a decoration. The problem is that I only can find text decoration and nothing that allows me to for example show a PNG between two lines of code without modifying the file.
Is this possible or I need to create a Custom Editor using the API? The problem of this solution is the need to integrate all the extension on the language I'm working what will take too much time.
I have seen the Comments API allows to show the reference of a text file but I can't find where is the API to generate this type of views:
The closest thing I can find is the Comments API with this sample. However, I need to add more than just text and the idea is to only show the content, nothing more.
Any guide, information or reference is highly appreciated.

Creating Diagram from Excel Using VB

Sorry I can't embed images, I have the links instead (... I can only post two links. I have removed the http:// substring from some of the links).
I am looking to take an .csv file (really, any file, as I am generating this myself), and create a Visio (2010) diagram out of it. I have successfully imported the excel sheet to Visio, and can create some rough diagrams, but they are not enough. This is what I'm trying to create. Here are the following tactics I have tried, I prefer the VB method, but whatever works works:
Data Graphics: This is the closest I've gotten to a solution. Basically you create shapes and you can put data in it. Problem is, the style of display available are limited, as we can see here (imgur.com/clTLcxk). After importing the excel sheet, all I had to do was drag and drop to create these shapes. The closest I have gotten is here. However, I really need the outside box (or container, for aesthetic reasons). (Some information here [support.office.com/en-us/article/Enhance-your-data-with-data-graphics-45af64a4-1dcb-4463-9a7e-67709786181c])
VB: I have been using this (msdn.microsoft.com/en-us/library/office/ff959245%28v=office.14%29.aspx). I have ran some of the example code, but I am really lost. I have run some of the example code but the only one I have really gotten to work are useless to me. Also, I don't see any API methods that actually add data to these diagrams!
So how is this done?
I would approach this problem by first defining or finding Visio masters that would the data I'm drawing to the page. In your case it looks like you'd want a master for your Foo items, and one for your Bar items.
So then you'd step through your Bars, then within each Bar you'd have one or more Foos. For each Foo, you would drop that master out, and set the text of the shape to what you want in the blue Foo section (maybe a grouped sub-shape for the Foo master), and then text in the white body.
When stepping through all the Bars, you'd obviously have to drop out a Bar shape and position/size it to contain all the Foos.

A Table of Contents Page for a Scanned PDF

I was given some really old but very useful hand-written notes recently and in a bid to preserve them, I had them scanned into a file in the PDF format. What I have is a 35 page PDF but I want to add a contents page at the beginning so that I can use the first page to click my way to a specific topic.
More precisely,
I want a page which says
Topic 1
Topic 2
Topic 3
...
Each one should be linked to a page of my choosing.
I've explored a lot of standard tools out there to help me with this, like LibreOffice, pdftk etc. but the solution does not appear to be in the form of a simple application and a few clicks. My hunch is that this will require a program written in a suitable language. The way I'd want this program to work as follows:
ProgramName Input.pdf CustomTOC.txt
Where CustomTOC.txt could be a simple ASCII table containing two columns, one column being the title and the second column being the page number. The output of this program will be another PDF file which contains one page appended at the beginning of Input.pdf containing a table of contents with hyperlinks to the right pages.
I have managed to solve this problem though I don't think this is the best way to do it. I have written a Python program that accepts two mandatory inputs - the input PDF file and '|' separated ASCII table containing columns and page numbers. A third optional output can be the name of a PDF file which contains the output. If this is not provided then the original input file is rewritten.
How the code works? Uses a system call to 'pdftk' for bursting the PDF file into its constituent pages. Writes a .tex file which contains a \listoffigures command for the first page with the package hyperref ensuring it links to the figures. The later part of the .tex code contains several figure insertion statements where the PDF file corresponding to each page is inserted, providing captions only to those PDFs for which there is an entry in the provided TOC table.
Why the code is not ideal? It relies on too many dependencies. It relies on a system call to the pdftk package, it requires that LaTeX be also installed on the machine with the graphics package. In the current version of the code, the PDFs on each page do have some offset which I am trying to solve using geometry package with custom margin settings. I will try to post the code once this problem is solved.
A more ideal solution. That which does not require LaTeX and can use some PDF library within Python to achieve the same effect. Comments and suggestions welcome!

How do I use Excel to insert blocks into AutoCAD drawings?

I'm trying to use Excel to create AutoCAD drawings. I have a list of product numbers and I'd like to use VBA so that upon hitting a button it will find a block or a drawing file of every product on the list and paste them into an AutoCAD drawing (to a specific point would be a bonus).
So far I've found code that will read from two columns in Excel and will plot a polyline in ACAD using those columns as coordinates. It's very simple but not exactly what I want. Does anyone have suggestions or example code that does something similar? I've found some online using the "ThisDrawing." object but Excel isn't recognizing that so I've reached a stand still. I have all day tomorrow to work on it, so I'll be doing a lot more searching, but any help is definitely appreciated. Thank you
Autodesk provide free downloads on their website so that you can add the VBA IDE into AutoCAD.
Then, inside the AutoCAD IDE you start a new VBA project.
Add a reference to your Excel library so that you can read the Excel spreadsheet.
You need to look up on:
ThisDrawing.ModelSpace.InsertBlock
In the AutoCAD VBA manual. It tells you what various parameters. But they are straightforward - origin, scale, rotation, path to block.
When you call the InsertBlock routine it will create a AcadBlockReference object. You can do any further customization on that object.

Insert a word from a predefined list of words

I'm looking for a way to create a VBA script in MS Word that displays a list of predefined words. If the user clicks on one, it will be inserted into the document. Google searches only showed a way to create mailings with values from Excel but I want the words to be hard coded inside that VBA script (array maybe?) without any external files. Here is a small mockup how I imagined it:
Any ideas or tutorial links on how to achieve somehing like this? It doesn't have to look like the dialog in the image but have a collection of words in a dialog for the user to select.
Edit: It would be nice if the user would see a human readable label (like 'First name') but the inserted value would be a variable (like '$firstName').
For creating the pop-up with a list of words, you can try something like this to connect a displayed value to the actual value.
As for the inserting into text part, this post seems to address the topic. Otherwise here's something from MSDN (http://support.microsoft.com/kb/212682/EN-US)
As it turns out, Greg Maxey has already built something very close to the requested utility by leveraging the native Building Blocks and AutoText features in Word. He calls his utility "Building Block Quick Pick" and the code for it is included in a free Word template add-in that contains a suite of Building Block utilities that he has created.
An article describing his Building Block utilities (with the Building Block Quick Pick detailed near the end) can be found here:
Gregory K. Maxey on Building Blocks & AutoText
The add-in can be downloaded from here:
Gregory K. Maxey's Building Block Enhanced Tools
The Building Block Quick Pick tool can be used as is or adopted to OP's exact format.
It's worth noting that one can also just create AutoText entries, place them in a template (for example, Building Blocks.dotx) and then place the Auto Text gallery on the QAT. This will provide a visual menu that with a single click will insert text at the insertion point. Here's what this would look like:
And here's a tutorial:
How to add AutoText from WikiHow