the title is self explanatory. However although I have figured out how
to implement the add-in from code, it consistently fails with the
message. "There is no active worksheet". I tried opening Excel to the
worksheet I want to import and then running the code but it didn't work.
I have posted the code in case anyone can spot my error.
---Code Start----
33230 On Error GoTo CmdOK_Click_Err or
33240 IntImportValue = Forms!frmImport Contacts.FrmeIm portChoice.Valu e
33250 If IsEmpty(IntImpo rtValue) Then
33260 Exit Sub
33270 Else
33280 Select Case IntImportValue
Case 1 'Import
Dim VUIObjectName As String
Dim VUIObjectType As Long
Dim SessionName As String
Dim Wbks As String
Dim SkipDuplicates As Boolean
Dim TruncateLongVal ues As Boolean
Dim ImportAllSheets As Boolean
Dim RunUnattended As Boolean
Dim CreateLogWorkbo oks As Boolean
Dim CloseXlImportFo rm As Boolean
Dim LogDir As String
Dim OpenLogWorkbook s As Boolean
Dim SessionName2Sav e As String
Dim CloseVUIObject As Boolean
Dim FolderToMoveWbk To As String
Dim fRet As Boolean
VUIObjectName = "Contacts"
VUIObjectType = acTable
SessionName = "ContactImp ort"
Wbks = "F:\Centre Stuff\Show Contacts
Database\Develo pment\MedtradeC ontacts2003.xls "
SkipDuplicates = True
TruncateLongVal ues = False
ImportAllSheets = False
RunUnattended = False
CloseXlImportFo rm = True
CreateLogWorkbo oks = False
LogDir = ""
OpenLogWorkbook s = False
SessionName2Sav e = "ContactImport( TABLE)"
CloseVUIObject = True
fRet = ftExcelImport( _
VUIObjectName, VUIObjectType, SessionName, _
Wbks, SkipDuplicates, TruncateLongVal ues, _
ImportAllSheets , RunUnattended, CreateLogWorkbo oks, _
CloseXlImportFo rm, LogDir, OpenLogWorkbook s, _
SessionName2Sav e, CloseVUIObject, FolderToMoveWbk To _
)
'(c) 4TOPS 2002-2003
If fRet = True Then
FormattedMsgBox "Congratulation s! @The contacts were
imported successfully!@" , vbInformation + vbOKOnly, "Success"
DoCmd.Close acForm, frmImportContac ts
Else:
FormattedMsgBox "The Import was not successful.@Ple ase talk
to your database administrator.@ ", vbInformation + vbOKOnly, "Failure!"
DoCmd.Close acForm, frmImportContac ts
End If
33550 Case 2 'Enter Manually
33560
33570 End Select
33580 End If
33590 On Error GoTo 33230
33600 Exit Sub
CmdOK_Click_Err or:
Dim ErrorNumber As Variant
Dim response As Integer
33610 Select Case ErrorNumber
Case 2501
33620 FormattedMsgBox "Error" & Err.Number + Err.Description &
"has occurred in procedure" & Err.Source & ".@ Please talk to your
database administrator.@ ", vbOKOnly + vbCritical, "Error!"
Case 2484
FormattedMsgBox "Error" & Err.Number + Err.Description &
"has occurred in procedure" & Err.Source & ".@ Please talk to your
database administrator.@ ", vbOKOnly + vbCritical, "Error!"
33630 End Select
End Sub
---Code End---
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!