Vba 导出日期字段并下拉到IE
我试图通过VBA将大约15个字段填充到IE中,并获得以下代码。当所有文本字段都被删除时,我无法填充日期字段和下拉字段Vba 导出日期字段并下拉到IE,vba,Vba,我试图通过VBA将大约15个字段填充到IE中,并获得以下代码。当所有文本字段都被删除时,我无法填充日期字段和下拉字段 Private Sub CommandButton4_Click() Dim IE As SHDocVw.InternetExplorer Dim URL As String URL = Sheet1.Range("A1").Value Set IE = GetIEWindow2 If IE Is Nothing Then
Private Sub CommandButton4_Click()
Dim IE As SHDocVw.InternetExplorer
Dim URL As String
URL = Sheet1.Range("A1").Value
Set IE = GetIEWindow2
If IE Is Nothing Then
Set IE = New SHDocVw.InternetExplorer
End If
With IE
.Visible = True
IE.Document.all(Sheet1.Range("F6").Value).Value = Sheet1.Range("B10").Value
IE.Document.all(Sheet1.Range("G6").Value).Value = Sheet1.Range("B11").Value
IE.Document.all(Sheet1.Range("H6").Value).Checked = True 'Entered
IE.Document.all(Sheet1.Range("I6").Value).Checked = True 'Entered
IE.Document.all(Sheet1.Range("J6").Value).Value = Sheet1.Range("B14").Value
IE.Document.all(Sheet1.Range("K6").Value).Value = Sheet1.Range("B15").Value
IE.Document.all(Sheet1.Range("L6").Value).Value = Sheet1.Range("B16").Value
IE.Document.all(Sheet1.Range("M6").Value).Value = Sheet1.Range("B17").Value
IE.Document.all(Sheet1.Range("N6").Value).Value = Sheet1.Range("B18").Value 'for date in the format 28/04/2015 00:00:00
IE.Document.all(Sheet1.Range("O6").Value).Value = Sheet1.Range("B19").Value
IE.Document.all(Sheet1.Range("P6").Value).Value = Sheet1.Range("B20").Value
IE.Document.all(Sheet1.Range("Q6").Value).Value = Sheet1.Range("B21").Value
**IE.Document.all(Sheet1.Range("R6").Value).Value = Sheet1.Range("B22").Value** 'this is for drop down
End With
End Sub
Private Function GetIEWindow2() As SHDocVw.InternetExplorer
'Look for an IE browser window and, if found, return that browser as an InternetExplorer object. Otherwise return Nothing
Dim Shell As Object
Dim IE As Object
Dim i As Variant 'Must be a Variant to index Shell.Windows.Item() array
Set Shell = CreateObject("Shell.Application")
i = 0
Set GetIEWindow2 = Nothing
While i < Shell.Windows.Count And GetIEWindow2 Is Nothing
Set IE = Shell.Windows.Item(i)
If Not IE Is Nothing Then
Debug.Print IE.LocationURL, IE.LocationName
If TypeName(IE) = "IWebBrowser2" Then
If TypeOf IE Is SHDocVw.InternetExplorer And IE.LocationURL <> "" And InStr(IE.LocationURL, "file://") <> 1 Then
Set GetIEWindow2 = IE
End If
End If
End If
i = i + 1
Wend
End Function
Private子命令按钮4\u单击()
Dim IE作为SHDocVw.InternetExplorer
将URL设置为字符串
URL=Sheet1.范围(“A1”).值
设置IE=GetIEWindow2
如果我什么都不是
设置IE=New SHDocVw.InternetExplorer
如果结束
与IE
.Visible=True
即文件全部(表1.范围(“F6”).值)。值=表1.范围(“B10”).值
即文件全部(表1.范围(“G6”).值)。值=表1.范围(“B11”).值
即文件全部(表1.范围(“H6”).值)。选中=真“已输入”
即文件全部(表1.范围(“I6”).值)。选中=真“已输入”
即文件全部(表1.范围(“J6”).值)。值=表1.范围(“B14”).值
即文件全部(表1.范围(“K6”).值)。值=表1.范围(“B15”).值
即文件全部(表1.范围(“L6”).值)。值=表1.范围(“B16”).值
即文件全部(表1.范围(“M6”).值)。值=表1.范围(“B17”).值
即文件所有(表1.范围(“N6”).值)。值=表1.范围(“B18”).值”,日期格式为2015年4月28日00:00:00
即文件全部(表1.范围(“O6”).值)。值=表1.范围(“B19”).值
即文件全部(表1.范围(“P6”).值)。值=表1.范围(“B20”).值
即文件全部(表1.范围(“Q6”).值)。值=表1.范围(“B21”).值
**例如,Document.all(Sheet1.Range(“R6”).Value).Value=Sheet1.Range(“B22”).Value**'这是用于下拉列表的
以
端接头
私有函数GetIEWindow2()作为SHDocVw.InternetExplorer
'查找IE浏览器窗口,如果找到,将该浏览器作为InternetExplorer对象返回。否则将不返回任何内容
作为对象的暗壳
模糊的物体
Dim i As Variant'必须是索引Shell.Windows.Item()数组的变量
Set Shell=CreateObject(“Shell.Application”)
i=0
设置GetIEWindow2=Nothing
而i