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_Error
33240 IntImportValue = Forms!frmImportContacts.FrmeImportChoice.Value
33250 If IsEmpty(IntImportValue) 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 TruncateLongValues As Boolean
Dim ImportAllSheets As Boolean
Dim RunUnattended As Boolean
Dim CreateLogWorkbooks As Boolean
Dim CloseXlImportForm As Boolean
Dim LogDir As String
Dim OpenLogWorkbooks As Boolean
Dim SessionName2Save As String
Dim CloseVUIObject As Boolean
Dim FolderToMoveWbkTo As String
Dim fRet As Boolean
VUIObjectName = "Contacts"
VUIObjectType = acTable
SessionName = "ContactImport"
Wbks = "F:\Centre Stuff\Show Contacts
Database\Development\MedtradeContacts2003.xls"
SkipDuplicates = True
TruncateLongValues = False
ImportAllSheets = False
RunUnattended = False
CloseXlImportForm = True
CreateLogWorkbooks = False
LogDir = ""
OpenLogWorkbooks = False
SessionName2Save = "ContactImport(TABLE)"
CloseVUIObject = True
fRet = ftExcelImport( _
VUIObjectName, VUIObjectType, SessionName, _
Wbks, SkipDuplicates, TruncateLongValues, _
ImportAllSheets, RunUnattended, CreateLogWorkbooks, _
CloseXlImportForm, LogDir, OpenLogWorkbooks, _
SessionName2Save, CloseVUIObject, FolderToMoveWbkTo _
)
'(c) 4TOPS 2002-2003
If fRet = True Then
FormattedMsgBox "Congratulations! @The contacts were
imported successfully!@", vbInformation + vbOKOnly, "Success"
DoCmd.Close acForm, frmImportContacts
Else:
FormattedMsgBox "The Import was not successful.@Please talk
to your database administrator.@", vbInformation + vbOKOnly, "Failure!"
DoCmd.Close acForm, frmImportContacts
End If
33550 Case 2 'Enter Manually
33560
33570 End Select
33580 End If
33590 On Error GoTo 33230
33600 Exit Sub
CmdOK_Click_Error:
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!