|
-
Apr 28th, 2015, 02:56 PM
#1
Thread Starter
New Member
Cannot create ActiveX component.
This is an issue where when the code hits ExcelObj = CreateObject("Excel.Application") line it throws the "Cannot create ActiveX component" error. Does anyone know why this is happening?
Sub SavePartNumbersInSession()
Dim ExcelObj As Object
'Dim ExcelBook As Object
'Dim ExcelSheet As Object
Dim i As Integer
Dim j As Integer
'Dim cells As Object
ExcelObj = CreateObject("Excel.Application")
'ExcelSheet = CreateObject("Excel.Sheet")
ExcelObj.WorkBooks.Open(sPath & "UploadedFiles\" & System.IO.Path.GetFileName(MyFile.PostedFile.FileName))
'ExcelBook = ExcelObj.Workbooks(1)
'ExcelSheet = ExcelBook.WorkSheets(1)
i = 1
j = 2
'cells = ExcelBook.WorkSheets(1).cells
Session("PartNumbers") = ""
Do Until ExcelObj.Workbooks(1).WorkSheets(1).cells(1, i).value & "" = ""
If ExcelObj.Workbooks(1).WorkSheets(1).cells(1, i).value = "Part Number" Then
ExcelObj.Workbooks(1).WorkSheets(1).UsedRange.Columns(i).NumberFormat = "@"
Do Until ExcelObj.Workbooks(1).WorkSheets(1).cells(j, i).value & "" = ""
'If IsNumeric(ExcelObj.Workbooks(1).WorkSheets(1).cells(j, i).value) Then
If Session("PartNumbers") <> "" Then
Session("PartNumbers") &= "|"
End If
Session("PartNumbers") &= CStr(ExcelObj.Workbooks(1).WorkSheets(1).cells(j, i).value)
' End If
j = j + 1
Loop
End If
i = i + 1
Loop
ExcelObj.DisplayAlerts = False
ExcelObj.Workbooks(1).Close()
ExcelObj.Quit()
ExcelObj = Nothing
End Sub
-
Apr 28th, 2015, 04:08 PM
#2
Re: Cannot create ActiveX component.
This is VB.Net code, not VB6 or earlier
-
Apr 28th, 2015, 04:41 PM
#3
Re: Cannot create ActiveX component.
At this link, CreateObject in .Net is described, along with a simple example of using it to automate Excel
-
Apr 28th, 2015, 04:57 PM
#4
Re: Cannot create ActiveX component.
Maybe add a 'Set' infront?
-
Apr 28th, 2015, 05:06 PM
#5
Re: Cannot create ActiveX component.
No need for multiple threads we will help when we can.
http://www.vbforums.com/showthread.p...won-t-turn-off
-
Apr 28th, 2015, 06:32 PM
#6
Re: Cannot create ActiveX component.
 Originally Posted by Max187Boucher
Maybe add a 'Set' infront?
You don't use Set in .Net. You can assign objects to object variables the same way you assign values to primitive types.
Maybe a mod should move this thread.
-
Apr 29th, 2015, 08:03 AM
#7
Re: Cannot create ActiveX component.
...and maybe a mod has
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|