Hi...
I'm trying to use VBA to create a ComboBox in Visio, populated by the fields (Rows?) in the shape data.
The reasoning: There is an organisation chart which contains the names and positions of employees. I have created code that inserts a new field, but left it blank so that the user can enter data at a later date. Now, I want to create a UserForm that contains a ComboBox of all the fields (Rows?) in each shape (person). This way, the user can choose which field to update. After selection, this will start another macro which then prompts the user to enter a value against each shape sequentially - this part has already been written and will only need minor tweaking later. All fields (rows?) are the same for each shape.
Please explain in laymean's terms as I am new to Visio and not an expert VBA user (I would consider myself beginner/intermediate!)
Thanks in advance!
sometimes ago i create userform with comboboxes which data contain in TheDoc!user cells
you can download this file there (http://visio.getbb.ru/download/file.php?id=304)
Look in UserForm_Initialize routine there you find load combobox list
Thanks Surrogate, but your file didn't open correctly. I couldn't see the code.
huh ?
Private Sub UserForm_Initialize()
fst = True
Me.txtTitul.Text = Replace(ActiveDocument.DocumentSheet.Cells("user.titul").FormulaU, Chr(34), "")
Me.txtObject.Text = Replace(ActiveDocument.DocumentSheet.Cells("user.Object").FormulaU, Chr(34), "")
Me.txtDec.Text = Replace(ActiveDocument.DocumentSheet.Cells("user.dec").FormulaU, Chr(34), "")
Me.txtManufact.Text = Replace(ActiveDocument.DocumentSheet.Cells("user.Manufact").FormulaU, Chr(34), "")
Me.txtBook.Text = Replace(ActiveDocument.DocumentSheet.Cells("user.Book").FormulaU, Chr(34), "")
Me.DTP1.Value = Replace(ActiveDocument.DocumentSheet.Cells("user.date").FormulaU, Chr(34), "")
cmbAuthor.List = Split(Replace(ActiveDocument.DocumentSheet.Cells("prop.author.format").FormulaU, Chr(34), ""), ";")
cmbAuthor.Text = Replace(ActiveDocument.DocumentSheet.Cells("prop.author").FormulaU, Chr(34), "")
cmbControl.List = Split(Replace(ActiveDocument.DocumentSheet.Cells("prop.control.format").FormulaU, Chr(34), ""), ";")
cmbControl.Text = Replace(ActiveDocument.DocumentSheet.Cells("prop.control").FormulaU, Chr(34), "")
cmbGIP.List = Split(Replace(ActiveDocument.DocumentSheet.Cells("prop.gip.format").FormulaU, Chr(34), ""), ";")
cmbGIP.Text = Replace(ActiveDocument.DocumentSheet.Cells("prop.gip").FormulaU, Chr(34), "")
cmbNCont.List = Split(Replace(ActiveDocument.DocumentSheet.Cells("prop.ncont.format").FormulaU, Chr(34), ""), ";")
cmbNCont.Text = Replace(ActiveDocument.DocumentSheet.Cells("prop.ncont").FormulaU, Chr(34), "")
cmbUtv.List = Split(Replace(ActiveDocument.DocumentSheet.Cells("prop.utv.format").FormulaU, Chr(34), ""), ";")
cmbUtv.Text = Replace(ActiveDocument.DocumentSheet.Cells("prop.utv").FormulaU, Chr(34), "")
fst = False
End Sub
I haven't had a chance to look at this yet, but will give feedback when I can.
Thanks!
Thanks for the code, but I did find an alternative way of getting the list.
Dim intCount As Integer
Dim intLoopCounter As Integer
Dim strFieldValue As String
Dim vsoPage As Visio.Page, vsoShape As Visio.Shape
intLoopCounter = 0
intCount = 0
Set vsoPage = ActiveDocument.Pages("Core")
Set vsoShape = vsoPage.Shapes.ItemFromID(12)
intCount = vsoShape.RowCount(Visio.visSectionProp)
Do Until intLoopCounter = intCount
strFieldValue = vsoShape.Section(visSectionProp).Row(intLoopCounter).Name
With ComboBox1
.AddItem strFieldValue
End With
intLoopCounter = intLoopCounter + 1
Loop
This looks at a shape on a page, counts how many rows it has, then uses this as a counter to scroll through getting the row names and adding them to the ComboBox!!
p.s. I don't know how to enter code into here and show it like you have - so apologies for that!
Browser ID: smf
(is_webkit)
Templates: 1:
Printpage (default).
Sub templates: 4:
init,
print_above,
main,
print_below.
Language files: 1:
index+Modifications.english (default).
Style sheets: 0:
.
Hooks called: 55 (
showintegrate_autoload, cache_get_data, integrate_pre_load, integrate_load_session, integrate_verify_user, cache_get_data, integrate_user_info, integrate_load_board, cache_get_data, integrate_board_info, cache_get_data, integrate_allowed_to_general, integrate_pre_load_theme, cache_get_data, integrate_allowed_to_general, integrate_simple_actions, integrate_allowed_to_general, integrate_load_theme, integrate_pre_log_stats, integrate_actions, integrate_pre_parsebbc, integrate_bbc_codes, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_menu_buttons, integrate_current_action, integrate_theme_context, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general)
Files included: 25 - 925KB. (
show/home/iw0lkfe3x6cq/public_html/vgforum/index.php, /home/iw0lkfe3x6cq/public_html/vgforum/Settings.php, /home/iw0lkfe3x6cq/public_html/vgforum/cache/db_last_error.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/QueryString.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Auth.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Errors.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Load.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Security.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Compat.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Db-mysql.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApi.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApiInterface.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/APIs/FileBased.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Charset.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/Metadata.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/QuickCheck.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Session.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Logging.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Class-BrowserDetect.php, (Current Theme)/languages/index.english.php, (Current Theme)/languages/Modifications.english.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Printpage.php, (Current Theme)/Printpage.template.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/CaseUpper.php)
Memory used: 773KB.
Tokens:
post-login.
Cache hits: 6: 0.00100s for 22,291 bytes (
showget modSettings: 0.00044s - 19982 bytes, get known_languages: 0.00026s - 1277 bytes, get board_parents-0: 0.00010s - 2 bytes, get permissions:-1: 0.00007s - 50 bytes, get theme_settings-1: 0.00010s - 980 bytes, get menu_buttons--1-english: 0.00001s - 0 bytes)
Cache misses: 1: (
showget menu_buttons--1-english)
Queries used: 8.
[Show Queries]