I been trying to call a VBA function from c# to automate some process, the problem is that when the Excel.Application visibility is false I get this error:
The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
When the visibility is true everything works perfectly but the it opens the excel application and I need to keep this process in the background not in the foreground, any idea?
Thanks!
Function DetermineStructureUpdates(DataDBPathAndName As String, DataCopyDBPathAndName As String, SyncDBPathAndName As String, DataDBPw As String, SyncDBPw As String) As String
dbDataPathAndName = DataDBPathAndName
dbDataCopyPathAndName = DataCopyDBPathAndName
dbSyncPathAndName = SyncDBPathAndName
dbDataPW = DataDBPw
dbSyncPW = SyncDBPw
AppActivate Application.Caption 'Bring Excel to the foreground
On Error GoTo ErrorHandling
Call DetermineDBStructure
If ErrorMessage <> "" Then GoTo ErrorHandling
DetermineStructureUpdates = "Success"
Exit Function
ErrorHandling: DetermineStructureUpdates = ErrorToReturn End Function
User contributions licensed under CC BY-SA 3.0