gdanalakshmi
Registered User.
- Local time
- Today, 03:51
- Joined
- Nov 26, 2002
- Messages
- 102
I am trying to attach an selected list of excel documents.
When I do for 1 particular document, I am getting the subscript out of range error? Where could I have gone wrong?
DocArrayIndex = 0
For Each DocItemI In Me.DocListbox.ItemsSelected
DocArrayIndex = DocArrayIndex + 1
Next DocItemI
ReDim DocSentIDArray(DocArrayIndex)
DocArrayIndex = 0
For Each DocItem In Me.DocListbox.ItemsSelected
DocSentIDArray(DocArrayIndex).Document_ID = Me.DocListbox.Column(3, DocItem)
DocArrayIndex = DocArrayIndex + 1
If Me.DocListbox.Column(4, DocItem) = False Then
'Something
Else
DocName = Me.DocListbox.Column(1, DocItem)
QryFileName = "C:\My Documents\" & _
[Forms]![MoveRequestDetail]![HelpDeskWO] & " - " & DocName & ".xls"
QRYName = Me.DocListbox.Column(5, DocItem)
'\\ QryFileName = Me.DocListbox.Column(2, Item)
DoCmd.OutputTo acOutputQuery, QRYName, acFormatXLS, _
QryFileName, False
' Set the object variable to reference the file you want to see.
Set ExcelApp = GetObject(QryFileName)
With ExcelApp
.Application.Visible = False
'ExcelApp.Parent.Windows(1).Visible = False
.Parent.Windows(1).Visible = True
.Worksheets(QRYName).Visible = True [[I GET AN ERROR AT THIS PLACE]]
' Make the columns autofit the data.
.Worksheets(QRYName).Columns("A:AX").AutoFit
.Save
.Close
End With
When I do for 1 particular document, I am getting the subscript out of range error? Where could I have gone wrong?
DocArrayIndex = 0
For Each DocItemI In Me.DocListbox.ItemsSelected
DocArrayIndex = DocArrayIndex + 1
Next DocItemI
ReDim DocSentIDArray(DocArrayIndex)
DocArrayIndex = 0
For Each DocItem In Me.DocListbox.ItemsSelected
DocSentIDArray(DocArrayIndex).Document_ID = Me.DocListbox.Column(3, DocItem)
DocArrayIndex = DocArrayIndex + 1
If Me.DocListbox.Column(4, DocItem) = False Then
'Something
Else
DocName = Me.DocListbox.Column(1, DocItem)
QryFileName = "C:\My Documents\" & _
[Forms]![MoveRequestDetail]![HelpDeskWO] & " - " & DocName & ".xls"
QRYName = Me.DocListbox.Column(5, DocItem)
'\\ QryFileName = Me.DocListbox.Column(2, Item)
DoCmd.OutputTo acOutputQuery, QRYName, acFormatXLS, _
QryFileName, False
' Set the object variable to reference the file you want to see.
Set ExcelApp = GetObject(QryFileName)
With ExcelApp
.Application.Visible = False
'ExcelApp.Parent.Windows(1).Visible = False
.Parent.Windows(1).Visible = True
.Worksheets(QRYName).Visible = True [[I GET AN ERROR AT THIS PLACE]]
' Make the columns autofit the data.
.Worksheets(QRYName).Columns("A:AX").AutoFit
.Save
.Close
End With