Smith and Andersen
asked on
Button OnClick and combo box
I am creating a new tab in word 2010 for custom templates
My xml file is working great and adds 5 buttons on the tab inserted after the info tab. Beside each button I have a combo box that has 9 items
can anyone tell me how I can make my button onAction event open a
OpenFileDialog() based on the cbo selection??
Here is the code I am trying
Sub OnAction(ByVal control As IRibbonControl)
Dim myStream As Stream = Nothing
Dim openFileDialog1 As New OpenFileDialog()
If "cbo01" = "item01" Then
openFileDialog1.InitialDir ectory = \\xxxxxxxxxxx
ElseIf "cbo1" = "item02" Then
openFileDialog1.InitialDir ectory = \\xxxxxxxx
ElseIf "cbo1" = "item03" Then
openFileDialog1.InitialDir ectory = \\xxxxxx
ElseIf "cbo1" = "item04" Then
openFileDialog1.InitialDir ectory = \\xxxxxxx
ElseIf "cbo1" = "item05" Then
openFileDialog1.InitialDir ectory = \\xxxxxxxxx
ElseIf "cbo1" = "item06" Then
openFileDialog1.InitialDir ectory = \\xxxxxxxxx
ElseIf "cbo1" = "item07" Then
openFileDialog1.InitialDir ectory = \\xxxxxxxxx
ElseIf "cbo1" = "item08" Then
openFileDialog1.InitialDir ectory = \\xxxxxxxx
ElseIf "cbo1" = "item09" Then
openFileDialog1.InitialDir ectory = \\xxxxxxxx
End If
openFileDialog1.ShowDialog ()
End Sub
TIA
My xml file is working great and adds 5 buttons on the tab inserted after the info tab. Beside each button I have a combo box that has 9 items
can anyone tell me how I can make my button onAction event open a
OpenFileDialog() based on the cbo selection??
Here is the code I am trying
Sub OnAction(ByVal control As IRibbonControl)
Dim myStream As Stream = Nothing
Dim openFileDialog1 As New OpenFileDialog()
If "cbo01" = "item01" Then
openFileDialog1.InitialDir
ElseIf "cbo1" = "item02" Then
openFileDialog1.InitialDir
ElseIf "cbo1" = "item03" Then
openFileDialog1.InitialDir
ElseIf "cbo1" = "item04" Then
openFileDialog1.InitialDir
ElseIf "cbo1" = "item05" Then
openFileDialog1.InitialDir
ElseIf "cbo1" = "item06" Then
openFileDialog1.InitialDir
ElseIf "cbo1" = "item07" Then
openFileDialog1.InitialDir
ElseIf "cbo1" = "item08" Then
openFileDialog1.InitialDir
ElseIf "cbo1" = "item09" Then
openFileDialog1.InitialDir
End If
openFileDialog1.ShowDialog
End Sub
TIA
Is the text displayed in combobox not path of directory? If it is, you can use that as initialdirectory value
openfiledialog1.initialdir ectory = cbo1.text
if its not, you can set the text and value of the combobox when populating and then
openfiledialog.initialdire ctory = cbo1.selectedvalue
openfiledialog1.initialdir
if its not, you can set the text and value of the combobox when populating and then
openfiledialog.initialdire
ASKER
Hi Codecruiser
The text displayed in the combobox is drawn from the xml file
<comboBox id="cbo01" label="Template Type" >
<item id="item01" label="01-Proposal"/>
<item id="item02" label="02-Project Admin"/>
<item id="item03" label="03-Permit Docs"/>
<item id="item04" label="04-Construction Admin"/>
<item id="item05" label="05-Inter-Office"/>
<item id="item06" label="06-Prime Consultant"/>
<item id="item07" label="07-CheckLists"/>
<item id="item08" label="08-FootPrint"/>
<item id="item09" label="09-Test-Dont Use"/>
The text displayed in the combobox is drawn from the xml file
<comboBox id="cbo01" label="Template Type" >
<item id="item01" label="01-Proposal"/>
<item id="item02" label="02-Project Admin"/>
<item id="item03" label="03-Permit Docs"/>
<item id="item04" label="04-Construction Admin"/>
<item id="item05" label="05-Inter-Office"/>
<item id="item06" label="06-Prime Consultant"/>
<item id="item07" label="07-CheckLists"/>
<item id="item08" label="08-FootPrint"/>
<item id="item09" label="09-Test-Dont Use"/>
Where do you get the actual path?
ASKER
This is the code I have been trying
Sub OnAction(ByVal control As IRibbonControl)
Dim myStream As Stream = Nothing
Dim openFileDialog1 As New OpenFileDialog()
If "cbo01" = "item01" Then
openFileDialog1.InitialDir ectory = "\\torvsrvfile\officetempl ates$\Toro ntoOfficeT emplates\0 1-Proposal "
ElseIf "cbo1" = "item02" Then
openFileDialog1.InitialDir ectory = "\\torvsrvfile\officetempl ates$\Toro ntoOfficeT emplates\0 2-Project admin"
ElseIf "cbo1" = "item03" Then
openFileDialog1.InitialDir ectory = "\\torvsrvfile\officetempl ates$\Toro ntoOfficeT emplates\0 3-Permit Documents"
ElseIf "cbo1" = "item04" Then
openFileDialog1.InitialDir ectory = "\\torvsrvfile\officetempl ates$\Toro ntoOfficeT emplates\0 4-Construc tion Admin"
ElseIf "cbo1" = "item05" Then
openFileDialog1.InitialDir ectory = "\\torvsrvfile\officetempl ates$\Toro ntoOfficeT emplates\0 5-Inter-Of fice"
Sub OnAction(ByVal control As IRibbonControl)
Dim myStream As Stream = Nothing
Dim openFileDialog1 As New OpenFileDialog()
If "cbo01" = "item01" Then
openFileDialog1.InitialDir
ElseIf "cbo1" = "item02" Then
openFileDialog1.InitialDir
ElseIf "cbo1" = "item03" Then
openFileDialog1.InitialDir
ElseIf "cbo1" = "item04" Then
openFileDialog1.InitialDir
ElseIf "cbo1" = "item05" Then
openFileDialog1.InitialDir
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
gman84 got onto it before I could.
It appears that the text in your combobox is actually the foldername that you are trying to set. If this is always the case then you can use the code suggested above to simplify it.
It appears that the text in your combobox is actually the foldername that you are trying to set. If this is always the case then you can use the code suggested above to simplify it.
e.g.
Open in new window