enari
asked on
excel automation inside VB missing declarations
Hi.
I have an excel sheet inside my VB application. I need to make a drop down box for selections.
The code to make the drop down, according to the VBA inside Excel is:
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertSt op, Operator:= _
xlBetween, Formula1:="=$A$2:$A$4"
Only problem, is inside VB, it does not recognize "xlValidateList" or "xlValidAlertStop" or "xlBetween"
It IS clunky having to use Excel inside VB, but unfortunatly i need it.
I have the following references:
* axowc11
* excel
* microsoft.office.core
*OWC11
What am i missing?
Thanks
Victoria
I have an excel sheet inside my VB application. I need to make a drop down box for selections.
The code to make the drop down, according to the VBA inside Excel is:
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertSt
xlBetween, Formula1:="=$A$2:$A$4"
Only problem, is inside VB, it does not recognize "xlValidateList" or "xlValidAlertStop" or "xlBetween"
It IS clunky having to use Excel inside VB, but unfortunatly i need it.
I have the following references:
* axowc11
* excel
* microsoft.office.core
*OWC11
What am i missing?
Thanks
Victoria
ASKER
Thanks, but I get the following error then:
Namespace or type 'Interop' for the Imports 'Microsoft.Office.Interop' cannot be found.
Namespace or type 'Interop' for the Imports 'Microsoft.Office.Interop'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ASKER
except...
Run-time exception thrown : System.MissingMemberExcept ion - Public member 'Validation' on type 'Range' not found.
For i = 2 To irows - 1
For j = 2 To icols - 1
loc = Me.cbxAlpha.Text & i
With Me.SpdAttend.Worksheets(1) .range("b5 ").Validat ion
.Delete()
.Add(Type:=Microsoft.Offic e.Interop. Excel.XlDV Type.xlVal idateList, AlertStyle:=Excel.XlDVAler tStyle.xlV alidAlertS top, Operator:=Excel.XlFormatCo nditionOpe rator.xlBe tween, Formula1:="=$Z$1:$Z$4")
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Run-time exception thrown : System.MissingMemberExcept
For i = 2 To irows - 1
For j = 2 To icols - 1
loc = Me.cbxAlpha.Text & i
With Me.SpdAttend.Worksheets(1)
.Delete()
.Add(Type:=Microsoft.Offic
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Add this line before your class:
Imports Microsoft.Office.Interop
And then, VB will recognize it:
Excel.XlDVType.xlValidateL
Excel.XlDVAlertStyle.xlVal
Excel.XlFormatConditionOpe
Cheers!