Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OrgChart向导通过VBA导出到Visio时出错_Vba_Automation_Visio_Orgchart - Fatal编程技术网

OrgChart向导通过VBA导出到Visio时出错

OrgChart向导通过VBA导出到Visio时出错,vba,automation,visio,orgchart,Vba,Automation,Visio,Orgchart,我正在尝试使用OrgChart向导通过VBA从Visual Studio导出Visio图形 首先,我们使用以下方法设置页面配置参数: '/PAGES=<top employee> <num levels> PAGENAME=<pagename>,<top employee> <num levels> PAGENAME=<pagename>... strPageConfig = " /PAGES=" & ListBo

我正在尝试使用OrgChart向导通过VBA从Visual Studio导出Visio图形

首先,我们使用以下方法设置页面配置参数:

'/PAGES=<top employee> <num levels> PAGENAME=<pagename>,<top employee> <num levels> PAGENAME=<pagename>...
 strPageConfig = " /PAGES=" & ListBox1.SelectedItem & " " & lvlNum & " PAGENAME=cleanedData"
添加组织结构图参数并运行向导:

orgWizArgs = " /FILENAME=" & visExcelFile & " /NAME-FIELD=Name" &
        " /MANAGER-FIELD=Reports_To" & strPageConfig &
        "/DISPLAY-FIELDS=Name, Title /SYNC-ACROSS-PAGES /HYPERLINK-ACROSS-PAGES"

objAddOn.Run("/S-ARGSTR " + orgWizArgs)
objAddOn.Run("/S-RUN")
visApp.visible = True
错误来自我们设置strPageConfig的那一行,特别是从ListBox1读取名称时。当值中有空格时,我会为每个单词(2或3,因为它们是名称)弹出一个窗口,说明:

我遗漏或忘记了什么导致空格导致此错误

导致另一个问题的解决方法是,当我们将员工姓名加载到ListBox1中时,我们将空格替换为u,但这些下划线会显示在图形中,这是我们不希望看到的

所以我的问题是: 如何使用包含空格的数据从VBA运行OrgChart向导? 或: 如何通过VBA进入这些对象并编辑ShapeData文本字段

我在其他网站上看到过类似的问题,但没有答案。
我也在使用Visio 2013

您需要引用字符串,因此:

Public Function QuoteString(str as String) as String

    Dim quotechar as String
    quotechar = Chr(34)

    QuoteString = quotechar & str & quotechar

End Function


strPageConfig = " /PAGES=" & QuoteString(ListBox1.SelectedItem) & " " & lvlNum & " PAGENAME=cleanedData"

您需要引用字符串,因此:

Public Function QuoteString(str as String) as String

    Dim quotechar as String
    quotechar = Chr(34)

    QuoteString = quotechar & str & quotechar

End Function


strPageConfig = " /PAGES=" & QuoteString(ListBox1.SelectedItem) & " " & lvlNum & " PAGENAME=cleanedData"
Public Function QuoteString(str as String) as String

    Dim quotechar as String
    quotechar = Chr(34)

    QuoteString = quotechar & str & quotechar

End Function


strPageConfig = " /PAGES=" & QuoteString(ListBox1.SelectedItem) & " " & lvlNum & " PAGENAME=cleanedData"