Marco - newbie need help

prem shared this question 9 months ago
Discussion Open

Hello all,


I'm totally a newbie in macro and would really appreciate if someone can help me create 3 macros that would in an entire map:

Macro 1: remove "<" and ">" from the following strings <firstname.name@domain.com>

Macro 2: create a topic with "firstname + name" and subtopic with firstname.name@domain.com

Macro 3: split into multiple topics/subtopics a list of emails addresses that are ";" separated such in the following example : name1, firstname1 <xxxxx@domain.com>;name2, firstname2 <xxxxx@domain.com>;name3, firstname3 <xxxxx@domain.com>...

Thanks a lot

Best Answer
photo

hi, i tested this script myself.


the last 2 lines are useless and cause error.


ps remove these 2 lines:

' Call the Main subroutine to execute the script

Main()


as seen, when AI is partnered with correct people,

it increase productivity.

thanks

Replies (7)

photo
1

Hello and welcome :)

If you are able to post screenshots of a map in "before" and "after" state, this would help with defining the macros.

Are you new to programming concepts, new to VBA-compatible macros, or only new to the MindManager object model?

photo
1

Hi there and thank you.
I'm totally new to VBA, unfortunately.
The use case is quite simple: I often do copy/paste email recipients from Outlook and would like to automate the reformatting of their name + email address.
Here's an example of what I'm trying to achieve.

7e6bf37cb5e5c5de6ffc166b9e7ab4d6


Thanks again

photo
1

Thank you for the clarification.

  1. You could get 80% of the way there manually, using a keyboard shortcut. Click in the topic text and put the cursor next to the semicolon, then press Alt + Shift + Right arrow. This will split the topic at the cursor, creating a new subtopic using the text to the right of the cursor. You can repeat this for multiple contacts, and also use it to split the name from the email address. Then you can rearrange the topics and clean up the detritus if needed. There are other related keyboard shortcuts that could be helpful - these are in the Keyboard Shortcuts document in MindManager Help, under "Topic Text".
  2. A single macro could do all of this in one step and across multiple topics. The approach I would take is to iterate over the selected topics (so that you can process multiple topics), skip topics that already have subtopics, and skip topics where the text does not match a regular expression, e.g. *,* <*>;* which should match 1 or more emails in the format you have shown. Then split the topic text into contacts first, and split each contact into name and email. Then insert the subtopics after the current topic, and finally delete the current topic. The slightly trickier parts are caching the selection first (as this collection will destroy itself) and inserting subtopics rather than appending them at the end of the subtopic collection.

photo
2

Hi,

Is your data source a table of names and addresses that you wish to import into a MindManager map? If so, you could copy or import it into Excel (or similar spreadsheet program that can read and write Excel files) and do some simple editing there before importing the results into MindManager using the Excel Data Mapper.

You shouldn't have to do very much beforehand; a simple search and replace in Excel could remove the brackets in your first example, and you could use simple Excel formulas to concatenate the first and last names into a single cell if they are not set up that way already.

Once the list is in a two-column format with name1, firstname1 (or firstname1 name1) in the first column and xxxx@domain.com in the second and saved as an Excel file, you can use the Data Mapper feature to import the list into MindManager. In the import dialogue you can designate the first column as a topic and the second as either a subtopic, a link, or both.

photo
1

Hi Alex,
Thanks for taking the time to reply to my post. Actually, my use case is pretty simple...I do copy a list of email recipients from Outlook and paste it in my maps (see above for an example) and I'd love to have an easy and automatic way to reformat the list with a minimum of manual steps.
Thanks again

photo
1

Yes - I can see the logic of writing a macro if you're going to do this often in small batches.

However, if you're only doing this occasionally with longer lists then importing via MindManager's Excel Data Mapper is fairly straightforward.

photo
1

Hi,

to delete specific text you could use the replace function
086aee0a791e3e1f6e026b4912ce6def

803b4384afa2c9c81c05a08de828ed3d

result

d9e95f1eefae3d62e5161ad4256a96a1

photo
1

I am here to show you, the light that never happened on the world before: AI

ps: indeed i am just a paid user, credits go to OpenAI and the contributors.


you just need purchase GPT4,

type:


You


for mindmanager winwrap macros, my friend wanna do this, can you help him? I'm totally a newbie in macro and would really appreciate if someone can help me create 3 macros that would in an entire map: Macro 1: remove "<" and ">" from the following strings <firstname.name@domain.com>


GPT replies:

Certainly! To create macros for MindManager using WinWrap Basic, you'll need to use the MindManager Object Model within the WinWrap Basic script environment. Below are examples of how your friend can create the macros to achieve the desired outcomes. Please note that these scripts are basic examples and might need adjustments based on the specific version of MindManager and its scripting environment.


### Macro 1: Remove "<" and ">" from Email Strings


This macro iterates through all topics in the map, checks if the topic text contains an email-like string enclosed in "<" and ">", and then removes the "<" and ">" characters.


```vb

Sub RemoveAngleBracketsFromEmails()

Dim objTopic As Topic

For Each objTopic In ActiveDocument.Range(mmRangeAllTopics)

If InStr(objTopic.Text, "<") > 0 And InStr(objTopic.Text, ">") > 0 Then

' Assuming the email is the only content in the topic

objTopic.Text = Replace(objTopic.Text, "<", "")

objTopic.Text = Replace(objTopic.Text, ">", "")

End If

Next objTopic

End Sub

```


### How to Use This Macro


1. **Open MindManager**: Launch the MindManager application.

2. **Access the Macro Editor**: Navigate to the macro editor or scripting environment. This can usually be done from the "Tools" menu, where you might find an option like "Macros" or "Scripting."

3. **Create a New Macro**: Choose to create a new macro/script. There might be a button or link to "New" or "Create."

4. **Copy and Paste the Code**: Copy the provided VBScript code into the macro editor.

5. **Save and Run the Macro**: Save the macro with a meaningful name, such as "RemoveAngleBracketsFromEmails." Then, run the macro on your active MindManager map.


Please ensure your friend follows these steps carefully and understands that running macros can modify map content. It's a good idea to make a backup of the map before running any macros.


If your friend encounters any issues or needs further customization, they might need to dive deeper into the MindManager scripting documentation or seek assistance from someone with experience in WinWrap Basic and the MindManager Object Model.

photo
1

btw, MM winwrap sometimes differ from VBA,

sometimes, you need to remove the App/Application in the code.


i didn't run this code,

but so far, it looks good.

you may try run it, and then see what error is reported.

you can feed back into GPT4 for trouble shooting, or consult experts.

photo
1

btw, GPT4 presented the above as a function,

shd use the following script:

Sub Main()

Dim objTopic As Topic

For Each objTopic In ActiveDocument.Range(mmRangeAllTopics)

If InStr(objTopic.Text, "<") > 0 And InStr(objTopic.Text, ">") > 0 Then

' Assuming the email is the only content in the topic

objTopic.Text = Replace(objTopic.Text, "<", "")

objTopic.Text = Replace(objTopic.Text, ">", "")

End If

Next objTopic

End Sub


' Call the Main subroutine to execute the script

Main()

photo
1

Fantastic ! That works like a charm. Thanks a lot to you and to ChatGPT. This is really awesome what we can do nowadays 😉

photo
1

worked? okay so i saved some time no need to test myself.


as pointed out in another post,

AI at this moment is still ASSISTANT only, semi-auto.

you still need to learn how to use a gun to shoot a target,

monkeys, with no aim no mind, shoots into the sky.

we all LEARN through out our lives.

photo
1

hi, i tested this script myself.


the last 2 lines are useless and cause error.


ps remove these 2 lines:

' Call the Main subroutine to execute the script

Main()


as seen, when AI is partnered with correct people,

it increase productivity.

thanks

photo
1

Actually, I haven't included them, so everything worked from the start.

photo
1

@Krsto: if it's not too much to ask, would you mind asking your AI friend an additionnal script to:

  1. Iterate over selected topics.
  2. For each selected topic, check if the text matches the pattern of an email address eg. firstname.name@domain.com
  3. Split the email address into "firstname name" by selecting everything that is before the "@"
  4. Append as a parent a topic before the current topic with the content "firstname name".
    so basicaly I would like a macro that would transform firstname.name@domain.com into 2 topics "firstname name" (parent topic) and the email address as a subtopic.
    I'm not familiar to ChatGPT either ;-( Thanks again

photo
1

me:

chinese got a slang, saying teach someone to do fishing, is better than give him a fish. how do you say it in english?


GPT:

The English equivalent of the Chinese saying you're referring to is:

"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime."

This proverb emphasizes the value of teaching someone how to do something for themselves rather than doing it for them just once.

---