ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   problem writing an Excel file on server using Microsoft.ACE.OLEDB. (https://www.excelbanter.com/excel-programming/427895-problem-writing-excel-file-server-using-microsoft-ace-oledb.html)

sn

problem writing an Excel file on server using Microsoft.ACE.OLEDB.
 
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.

ryguy7272

problem writing an Excel file on server using Microsoft.ACE.OLEDB.
 
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---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"SN" wrote:

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.



All times are GMT +1. The time now is 09:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com