problem writing an Excel file on server using Microsoft.ACE.OLEDB.

  • Thread starter Thread starter SN
  • Start date Start date
S

SN

Hi,

I want to write an excel file on server from a client connection with
following code:

string ConnString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
Server.MapPath("../../ExcelTemplate/PrevalenceReportDownloadv2TEMPLATE.xls")
+ @";Extended Properties=""Excel 12.0;HDR=NO;""";

OleDbConnection cn = new OleDbConnection(ConnString);

cn.Open();

But, it fails to open the connection, giving following error:

System.InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is
not registered on the local machine

One thing here to note down is, the server has no office environment.
Does it need Office installed as a prerequisite ?
Or there is some other problem?

Hoping for a quick response.
Thanks for your help.

-Sulakshana.
 
If I understand you correctly, something like this may get you started:
Private Sub CommandButton2_Click()
Dim p As String
Dim f As String
Dim s As String
Dim r As String
Dim ws As Worksheet
p = "\\fsrv3\public\Sales Operations\Ryan\"
f = "East.xls"
s = "VP of Sales"
r = "I18:K20"
Set ws = ActiveSheet
Workbooks.Open (p & f)
' copy range values from current worksheet to same range in network file
ws.Range(r).Copy Workbooks(f).Worksheets(s).Range(r)
' close network file, saving changes
Workbooks(f).Close True
End Sub

Obviously, change to suit your specific situation!

Goodluck,
Ryan---
 
Back
Top