We can find many videos of using ChatGPT to get formulas and VBA code for MS Excel:
e.g. great Leila Gharani in her video "How ChatGPT Can Help With Your Complex Excel Spreadsheets"
Do any of you have experience using ChatGPT to write VBA code for Visio and ShapeSheet formulas?
Please share your insights :)
I previously brought up a similar top (https://visio.getbb.ru/viewtopic.php?f=18&t=1876)ic in the Russian-speaking community of Visio users
Taking into account the answers that ChatGPT has given me on other subjects I wouldn't trust its answers as far as I could shove it!
Funny, I tried that a few days ago and find the results impressive:
VBA code that lists all shapes in a visio document where Prop.Name eqals "Hello":
Sub ListShapesWithPropNameHello()
Dim vsoPage As Visio.Page
Dim vsoShape As Visio.Shape
For Each vsoPage In ActiveDocument.Pages
For Each vsoShape In vsoPage.Shapes
If vsoShape.CellExistsU("Prop.Name", 0) Then
If vsoShape.CellsU("Prop.Name").ResultStr(visUnitString) = "Hello" Then
Debug.Print vsoShape.Name
End If
End If
Next vsoShape
Next vsoPage
End Sub
Very cool, only replace visUnitString with visNone.
A Visio ShapeSheet formula that returs "large" if Prop.Size is greater than 20 and otherwise User.Value:
=IF(Prop.Size > 20, "Large", User.Value)
Perfect :)
I see it a bit like the macro recorder.
Not very helpful, but sometimes I have a look what it does.
Imagine what is possible in 10 years :o
I attach a screenshot to view the settings.
"text-davinci-003" gives much better results as the "code-davinci" models.
Can ChatGPT write new features for Visio desktop for Microsoft? Then we can get new stuff in Visio desktop, finally!
Have been playing with it for a while too, but it did not occur to me to think about Visio for it too (old man, too many brain cells already lost ;) ). Thanks Surrogate.
Here are some thoughts from my very own perspective.
- I did not suspect that it knows Visio too, since our "hobby" is very "niche".
- Writing routines similar to what Thomas provided is rather boring (sorry Thomas, no offence meant). That would be stuff for beginners, not people understanding the object model.
- An immense help would however be a code translator from Python to VBA - actually easy, but I haven't seen that yet. To explain myself: The beauty of python - as I perceive it - is that I can setup variable structures on the fly like "L = [[shp, shp.ID, shp.Cells('PinX').ResultIU] for shp in ActivePage.Shapes if shp.CellExists('prop.A',False)]" - This would give me a list of lists. The inner lists holding a shape as object, its ID and in this case its PinX. In VBA I would need for this 1-liner to declare an array (as variant), a temporary var for traversing the collection, a for loop, an IF statement, a REDIM statement, the whole thing twice since I'm collecting the shapes and their IDs, and so on. Another great feature are functions that return several results. In VBA "practically" impossible to implement (because of crapy array functions). So here it is, not so much the help with Visio, but to leverage the insufficiencies of VBA.
- Visio solutions must always consider the different tools that Visio offers - the shapesheet, templates, stencils, macros, addins, external data sources. Only when having considered this whole arsenal of "weapons" a solution can be good. I wonder how good ChatGPT would handle this complexity. Worth being tested.
Quote from: Visisthebest on March 11, 2023, 11:41:28 AM
Can ChatGPT write new features for Visio desktop for Microsoft? Then we can get new stuff in Visio desktop, finally!
How would that be possible? Reverse engineer an application, modify it, rewrite the code and compile?
Very imaginable, but not in 2023!
;)
Think about all the copyright issues. That would be the end of M$ and the like.
But may be I understood you wrong.
Quote from: Thomas Winkel on March 11, 2023, 11:07:15 AM
I attach a screenshot to view the settings.
"text-davinci-003" gives much better results as the "code-davinci" models.
What is that screenshot? My interface looks different. Can you send a link?
Quote from: Yacine on March 11, 2023, 01:41:25 PM
What is that screenshot? My interface looks different. Can you send a link?
https://platform.openai.com/playground
I was also surprised that ChatGPT is able to generate code for Visio because I thought that this is too specific.
But I think that it is very far away from being really helpful.
Maybe this could be integrated into IDEs to suggest code snippets while the user is typing.
But absolutely impressive, anyhow!
Another thought:
I can imagine a use case for the end user in not so far future.
Imagine MS would integrate that in Office while completely abstracting away code, formulas and all those complicated stuff.
The user would only formulate his request and Office would suggest a result (not a solution).
The user can accept or specify more precisely or rephrase the request or cancel.
I think this will be much more helpful for the standard user as the macro recorder is.
And with the results above in mind I bet that in a few years such a tool could solve many simple automation tasks in acceptable quality.
ChatGPT doesn't generate code, it copies it from elsewhere.
Quote from: Thomas Winkel on March 11, 2023, 06:22:32 PM
The user would only formulate his request and Office would suggest a result (not a solution).
I'm sorry, Thomas. I can't do that.
;D
Quote from: Paul Herber on March 11, 2023, 06:24:40 PM
ChatGPT doesn't generate code, it copies it from elsewhere.
Agree that it doesn't generate, but it's more than a copy. Maybe something between copy and create.
But to be honest, I also copy a lot of StackOverflow when programming ;D
Quote from: Paul Herber on March 11, 2023, 06:26:08 PM
I'm sorry, Thomas. I can't do that.
;D
;D
Would be a huge improvement if ChatGPT would be able to refuse, it always pretends a solution.
Here to take over the world:
VBA code to take over the world:
Sub TakeOverTheWorld()
Dim i As Integer
For i = 1 To 100
Call LaunchMissiles()
Call EstablishMilitaryDictatorship()
Call EstablishGlobalCurrency()
Next i
End Sub
8)
You forgot:
Call DeployExpendableMinions()
Call KillBondJamesBond()
Y'all must be smokin your socks. While what you've suggested as possible "calls", with the exception of Paul's kill call, which is neither possible (latest movie is clearly fictional), nor practical as it would require all of the preceding, but futile, calls.
It would seem that ultimately you have a call for each line of code. And if the call refers to a more complex function, then that too could have an extraordinary number of calls. I can see it now...error handler..." The line you called is busy. The average wait time is 30 minutes. Would you like to wait, or leave a call back number?"
I can hardly wait for the future! Long live James Bond! 🤔😖😜 🤓🤓🤓
Now this is cool.
Convert the following python code into VBA:
L = [[shp, shp.ID, shp.Cells('PinX')] for shp in ActivePage.Shapes if shp.CellExists('prop.A',False)]
I have tried the following:
<code>Dim L As Variant
Dim shp As Shape
Dim shpID As String
Dim shpPinX As String
For Each shp In ActivePage.Shapes
If shp.CellExists("prop.A", False) Then
L = shp
shpID = shp.ID
shpPinX = shp.Cells("PinX")
End If
Next shp
</code>
But I am getting an error on the line:
<code>L = shp
</code>
The error is:
<blockquote>
<p>Run-time error '13': Type mismatch</p>
</blockquote>
I am not sure how to fix this.
A:
You need to declare L as an array of arrays.
<code>Dim L As Variant
Dim shp As Shape
Dim shpID As String
Dim shpPinX As String
For Each shp In ActivePage.Shapes
If shp.CellExists("prop.A", False) Then
ReDim Preserve L
I tried first with the default engine text-davinci-003 and it got the answer wrong by re-assigning L to the inner shp only. Switching to code-davinci-002 showed the result above.
And, Paul, it works exactly as myself, try and error. (Yacine == impressed) = true
This is why I don't agree with you, it does generate. And everybody is copying anyway.
Mind, only the 2 first lines are mine!
Build a Visio solution where a user can drop a master on the drawing then define it by choosing a value from a list. The list must be generated dynamically from an external database. The ID defining this value should be displayed in the shape.
1. Create a Visio solution with the necessary shapes and stencils.
2. Connect the Visio solution to an external database with the necessary information.
3. Create a dropdown list in the Visio solution to allow users to select values from the external database.
4. Create a master shape in the Visio solution and add the dropdown list to it.
5. Define the logic for the dropdown list so that the selected value is displayed in the master shape.
6. Store the ID of the selected value in the master shape for future reference.
Still quite vague, and with errors (point 6), but hey for a start not bad.
That goes with Thomas' vision.
Write a shapesheet solution using the Index function and the lookup function to map two lists. You choose the nth element in one list and get the value of the nth element in the second list.
Start with creating two lists of items. For example, List1 is [A,B,C,D] and List2 is [1,2,3,4].
Then, use the Index and Lookup functions to map the two lists.
To get the value of the nth element in List2 using the nth element of List1, use the following formula:
=LOOKUP(INDEX(List1,n),List1,List2)
Where n is the index of the element.
For example, to get the value of the third element in List2 using the third element of List1, use the following formula:
=LOOKUP(INDEX(List1,3),List1,List2)
This will return the value 3.
Not bad neither, but I needed to tell it to use LOOKUP. Without the hint it proposes only INDEX.
Also the answer is wrong, as the second argument (List1) is not needed.
Open Research by University of Pennsylvania: An Early Look at the Labor Market Impact (https://arxiv.org/pdf/2303.10130.pdf)...
Ugh. That was long. Based upon Fig 1, the higher your education level, the greater your vulnerability. There's a motivator for learning. (Yeah, I like yanking chains. 😎)
I just asked it to create a macro I needed for work, and it did so quite impressively.
My Prompt:
please write a VBA macro for visio, which collects the texts of all the shape in a page into a long string (with a separator between the text of different shapes: ||| ), creates a new textbox, and place the long string as the text of the textbox, in red
The only think it got wrong is that the line which attempted to make the text red didn't work, so I deleted it (wasn't very important anyway, just for me to easily detect).
Sub CollectShapesText()
' Declare variables
Dim page As Visio.Page
Dim shape As Visio.Shape
Dim textBox As Visio.Shape
Dim textString As String
' Get the current page
Set page = ActivePage
' Loop through all shapes on the page
For Each shape In page.Shapes
' Check if shape has text
If shape.Characters.Text <> "" Then
' Add the shape's text to the string with separator
textString = textString & shape.Characters.Text & "|||"
End If
Next shape
' Create a new text box on the page
Set textBox = page.DrawRectangle(1, 1, 3, 3)
' Set the text box's text to the collected shape text in red
With textBox
.Characters.Text = textString
.CellsSRC(visCharacter, visCharacterColor).FormulaU = "RGB(255,0,0)"
End With
End Sub
Quote from: along on March 23, 2023, 01:43:39 PM.CellsSRC(visCharacter, visCharacterColor).FormulaU = "RGB(255,0,0)"
CellsSRC property (https://learn.microsoft.com/en-us/office/vba/api/Visio.Shape.CellsSRC) need 3 parameters:
Section,
Row,
Column!
Correct synax is
.CellsSRC(visSectionCharacter, 0, visCharacterColor).FormulaU = "RGB(255,0,0)"
Quote from: along on March 23, 2023, 01:43:39 PMMy Prompt:
please write a VBA macro for visio, which collects the texts of all the shape in a page into a long string (with a separator between the text of different shapes: ||| ), creates a new textbox, and place the long string as the text of the textbox, in red
I repeated your request and got a different answer. True, also with an error, but in a different place.
Public Sub CollectAndDisplayText()
Dim currentPage As Visio.Page
Set currentPage = ActivePage
Dim shapeText As String
shapeText = ""
Dim shape As Visio.shape
For Each shape In currentPage.Shapes
shapeText = shapeText & shape.Text & "|||"
Next shape
' Create a new textbox shape
Dim textShape As Visio.shape
Set textShape = currentPage.Drop(Application.Documents.Add("Text.vst").Masters("Text"), 5, 5) ' this line dont works (cant add new shape, from some template ?)
' Set the text of the new text shape to the concatenated shape text
textShape.Text = shapeText
' Set the text color to red
textShape.Cells("Char.Color").FormulaU = "RGB(255,0,0)" ' this line change font color correct
End Sub
I clearly relies on examples found in the net. It is not yet clever enough to know that Text.vst is not available to everyone.
Our community is too small. Questions relating to Excel are certainly better answered.
Quote from: Yacine on March 23, 2023, 03:49:06 PMOur community is too small.
You're right!
Quote from: Yacine on March 23, 2023, 03:49:06 PMQuestions relating to Excel are certainly better answered.
But we can teach ChatGPT!
I recently asked a question:
Surrogate: Strsame ShapeSheet.
ChatGPT: "Strsame" and "ShapeSheet" are two different things from different areas of programming.
"Strsame" is a C programming language function that is used to compare two strings for equality. It is prototyped by int strsame(char *s, char *t) and returns 1 if the strings s and t match, and 0 otherwise.
"ShapeSheet" is a technology that is used in Microsoft Visio and Microsoft Excel to create and edit graphical objects and diagrams. A ShapeSheet is a table that contains cells that can contain data about an object's shape, size, color, and other properties. ShapeSheet cells can be used to control the display of objects, as well as to make connections between objects.
I gave a link to an article about Visio's STRSAME function (https://learn.microsoft.com/en-us/office/client-developer/visio/strsame-function), asked what the article was about? didn't give a brief description.Surrogate: no contradiction?
ChatGPT: My apologies, I made a mistake in my previous reply. Indeed, the link you provided describes the STRSAME function of the ShapeSheet language used to compare two lines. I apologize for the confusion and incorrect information in the previous post.
... Today I asked the same question
Surrogate: Strsame ShapeSheet
ChatGPT: The STRSAME function is one of the ShapeSheet functions in Microsoft Visio and is used to compare two lines to determine if they are identical. The syntax of the STRSAME function is as follows: STRSAME(string1, string2), where string1 and string2 are the strings being compared.
The function returns TRUE if the two strings are identical and FALSE if they are different. The comparison of strings is case-sensitive, that is, the string "abc" and the string "ABC" will be different.
For example, if you want to check if the string contained in the "Prop.Row_1" cell is identical to the "Hello" string, you can use the following expression in the ShapeSheet formula cell:
STRSAME(Prop.Row_1, "Hello")
This expression will return TRUE if the value of the cell "Prop.Row_1" is "Hello", and FALSE otherwise.
(https://mysmailik.ru/_ph/26/2/780792161.gif?1679588169)
If ChatGPT can give a clear, understandable-for-everyone explanation of SETATREF() it is a genius!
Not always the "learning" stays in the memory.
About week ago i asked about our russian speaking Visio forum. Few times i get answers like visiofan.ru or visiofun.ru (these sites never existed).
Surrogate: https://visio.getbb.ru/index.php what is it about ?
ChatGPT: This site is a forum dedicated to Microsoft Visio. It is created for Visio users to communicate, share experience and knowledge about Visio. At the forum you can ask questions, share your findings, find solutions to problems related to Visio use. The site also features sections with information about news, updates, add-ons and useful hints for users.
Surrogate: how do you think it can be considered a Russian forum on Visio?
ChatGPT: Yes, forum https://visio.getbb.ru/index.php can be considered the Russian-speaking forum devoted to Visio subjects. On this forum users can communicate in Russian, ask questions, share experience and knowledge about Visio. There are also sections on the site with information about news, updates and useful tips on using the program.
Surrogate: remember it please
ChatGPT: Okay, I'll remember the forum https://visio.getbb.ru/index.php as a Russian-language forum dedicated to Visio topics. If you have any other questions, please feel free to contact me!
Now he offers visiofan.ru/visiofun.ru and forums on which contain Visio-related sections.
Quote from: Visisthebest on March 27, 2023, 10:26:09 AMit is a genius!
New experiments:
Surrogate: /ask most visited visio forum in the world
ChatGPT: It's difficult to determine the most popular Visio forum in the world, as there are many forums and online communities dedicated to Visio, and their popularity may depend on factors such as language, region, and user base. However, some of the most popular and active Visio forums include:
1. Microsoft Tech Community - Visio: A community forum for Visio users hosted by Microsoft.
2. Visio Guy: A forum for Visio users featuring tips, tutorials, and discussion on a range of topics.
3. Stack Overflow: A popular question-and-answer site for programming and software development, including Visio-related topics.
4. Reddit: The r/Visio subreddit is an active community for Visio users to share tips, ask questions, and discuss Visio-related topics.
These are just a few examples; there are many other Visio forums and communities online that you can explore.
I was especially amused that Microsoft Tech Community was at the top of the list!
ChatGPT obviously never develops for Visio because the Visguy forum is the one that rules them all!
Quote from: Yacine on March 23, 2023, 03:49:06 PM
Our community is too small.
and as more precise chatGPT is, the smaller this community here will be, isnt it?
Sure, but that will take some time.
Large Language Models have more limitations than people think, but they are very good at appearing to be very intelligent.
Quote from: Visisthebest on April 05, 2023, 09:44:56 AM
Large Language Models have more limitations than people think, but they are very good at appearing to be very intelligent.
Isn't it true for people too? Aren't we doing the same thing as these engines? Collecting, stealing, putting together? How often do we really do something new?
In my first Visio years I was quite "prolific", ten years later I'm just repeating what I really learned or invented a decade ago.
The things that changed are a better understanding of some key concepts and to ask the right questions (from the acquired experience). But that's something that these AI engines will certainly come up with in no time.
If a human come up with some answer there are plenty of other people who might question this, however, if the computer says it's true ...
The human brain is very different from a Large Language Model, and both have very distinct advantages.
But LLMs are the new toy, while human brains are at least tens of thousands of years old.
https://www.businessinsider.com/human-brains-may-only-be-40000-years-old-scientists-say-2018-1