Storing BASE64 strings in user fields

Started by Visisthebest, July 13, 2021, 07:55:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Visisthebest

To save a bit of space in data I want to store in some user fields, I would like to use BASE64 strings instead of HEX strings.

Because the BASE64 strings can have some trailing = (equal) signs for padding, is there any potential issue with using them?

Because a string is always within quotes (chr(34)) I would think not, but maybe I'm overlooking something.

In BASE64, both a / and a + are also possible.
Visio 2021 Professional

Surrogate

#1
I heard about the 65k character limit in User-defined cells (UDC) in oldest Visio versions. Just now i try this code for check how many characters i can put in UDC.
As first, I faced with limitation of string variable. For example variable with lenght of 1005000000 characters can work, but with 2000000000 can not.
Sub LimitUDC()
Dim sh As Shape, t As String
t = "=" & Space(1005000000) & "1"
Set sh = ActivePage.Shapes.ItemFromID(1)
sh.Cells("User.row_1").FormulaU = Chr(34) & t & Chr(34)
End Sub

This code can write these long strings to UDC, but it is very slow
Just now i have not examples of BASE64 strings. Few years ago i meet in one old MS blog png-pictures stores as BASE64 strings.

Surrogate

#2
I continued my experiments for lulz:
I find this service for encode pictures to BASE64 strings
Just encode my picture

i can't put this BASE64 string to variable via VBA-editor. Just paste it as shape's text. i changed my code to
Sub PNG-encodded()
Dim sh As Shape, t As String
Set sh = ActivePage.Shapes.ItemFromID(1)
t = sh.Text
sh.Cells("User.row_1").FormulaU = Chr(34) & t & Chr(34)
End Sub

In this case i get lenght of this string - 108008 characters.

Visisthebest

Thank you for trying Surrogate I was unaware we can store a lot more than 64 Kilobytes in a shape's user field now very handy!

For me shorter BASE64 strings work fine but I haven't tried all kinds of Visio object methods to read the data, so hopefully won't run in to a surprise later.
Visio 2021 Professional

Surrogate

@Visisthebest,

For what purposes do you use Base64 ?

Visisthebest

Storing binary data in Shape user fields.
Visio 2021 Professional

Surrogate

Quote from: Visisthebest on November 19, 2021, 10:46:11 AM
Storing binary data in Shape user fields.
Can you insert it as picture into shape ?

Visisthebest

Visio 2021 Professional