Worf

Draw the Ukrainian flag with VBA

Worf

Well-known Member
Joined
Oct 30, 2011
Messages
4,257
Worf submitted a new Excel article:

Draw the Ukrainian flag with VBA - This article shows six different ways to draw a flag.

The Ukrainian flag is rather easy to draw, and here we will see six distinct ways to do it:

  • 2 user forms without title and borders
  • 2 worksheet cells
  • A Word table
  • A chart
  • 2 shapes
  • 2 text boxes
View attachment 67398
View attachment 67399
VBA Code:
Option Explicit
Rem standard module
#If VBA7 Then
Private Declare PtrSafe Function FindWindow Lib "user32" _
    Alias "FindWindowA" (ByVal lpClassName As String, _
    ByVal lpWindowName As...

Read more about this Excel article...
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Here's another way:

VBA Code:
Sub DrawFlag()
    Dim Code(1 To 3) As String
    Dim Filename As String: Filename = Environ("TEMP") & "\flag.svg"
    Code(1) = "<svg width=""440"" height=""275"" xmlns=""http://www.w3.org/2000/svg"" xmlns:xlink=""http://www.w3.org/1999/xlink"" xml:space=""preserve"" overflow=""hidden"">"
    Code(2) = "<defs><clipPath id=""clip0""><rect x=""0"" y=""0"" width=""440"" height=""275""/></clipPath></defs>"
    Code(3) = "<g clip-path=""url(#clip0)""><rect x=""0"" y=""0"" width=""440"" height=""138"" fill=""#055AB4""/><rect x=""0"" y=""138"" width=""440"" height=""137"" fill=""#FAD205""/></g></svg>"
    CreateObject("Scripting.FileSystemObject").CreateTextFile(Filename, True).WriteLine Join(Code)
    Application.ActiveSheet.Shapes.AddPicture Filename:=Filename, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=Application.ActiveCell.Left, Top:=Application.ActiveCell.Top, Width:=-1, Height:=-1
    Kill Filename
End Sub
 

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top