This is a multipart message in MIME format.
--=_alternative 005EFF76C1257495_=
Content-Type: text/plain; charset="US-ASCII"
Hi,
I have a database from which I send data to several other databases.
Because in the other databases the suppliers may only see their own data
and I was looking into how I could send the data to the suppliers in an
automated way without that they can see the data when opening the file.
I have managed to ex****t the data out of the central database into excel
and to password protect this file on open.
I have also found some code on the internet on how to im****t the data but
when I use this I still need to enter the password manually twice.
I would like to be able to im****t this data in the background.
Ex****t code (working OK) :
Public Sub SaveXls(sFile As String)
On Error GoTo Err_Testing
Dim xlApp As Object
Dim xlSheet As Object
Set xlApp = CreateObject("Excel.Application")
Set xlSheet = xlApp.Workbooks.Open(sFile).Sheets(1)
With xlApp
'Password protext the active worksheet
.Application.ActiveSheet.Protect "xxx", UserInterfaceOnly:=True
'Password protect the workbook strcuture
.Application.ActiveWorkbook.Protect "xxx", Structure:=True,
Windows:=False
'Password protect the file [OnOpen password]
.Application.DisplayAlerts = False
.Application.ActiveWorkbook.SaveAs FileName:=sFile,
Password:="xxx", WriteResPassword:="xxx"
.Application.DisplayAlerts = True
.Application.ActiveWorkbook.Save
.Application.ActiveWorkbook.Close
.Quit
End With
Set xlApp = Nothing
Set xlSheet = Nothing
Exit_Testing:
Exit Sub
Err_Testing:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_Testing
End Sub
Im****t Code (not working OK):
Public Sub Im****tProtected(strFile As String, strPassword As String)
Dim oExcel As Object, oWb As Object
Set oExcel = CreateObject("Excel.Application")
Set oWb = oExcel.Workbooks.Open(FileName:=strFile, Password:=strPassword)
DoCmd.TransferSpreadsheet acIm****t, acSpreadsheetTypeExcel9, "Im****t",
strFile, -1
oWb.Close SaveChanges:=False
oExcel.Quit
Set oExcel = Nothing
End Sub
Can someone help me on this issue or inform me on how I can ex****t the
data in another way and keep the data hidden?
Regards,
Peter
--=_alternative 005EFF76C1257495_=
Content-Type: text/html; charset="US-ASCII"
<br><font size=2 face="sans-serif">Hi,</font>
<br>
<br><font size=2 face="sans-serif">I have a database from which I send
data to several other databases.</font>
<br><font size=2 face="sans-serif">Because in the other databases the
suppliers
may only see their own data and I was looking into how I could send the
data to the suppliers in an automated way without that they can see the
data when opening the file.</font>
<br><font size=2 face="sans-serif">I have managed to ex****t the data out
of the central database into excel and to password protect this file on
open.</font>
<br>
<br><font size=2 face="sans-serif">I have also found some code on the
internet
on how to im****t the data but when I use this I still need to enter the
password manually twice.</font>
<br><font size=2 face="sans-serif">I would like to be able to im****t this
data in the background.</font>
<br>
<br><font size=2 face="sans-serif">Ex****t code (working OK) :</font>
<br>
<br><tt><font size=2>Public Sub SaveXls(sFile As String)<br>
On Error GoTo Err_Testing<br>
<br>
Dim xlApp As Object<br>
Dim xlSheet As Object<br>
<br>
Set xlApp = CreateObject("Excel.Application")<br>
Set xlSheet = xlApp.Workbooks.Open(sFile).Sheets(1)<br>
<br>
With xlApp<br>
<br>
'Password protext the active worksheet<br>
.Application.ActiveSheet.Protect
"xxx",
UserInterfaceOnly:=True<br>
<br>
'Password protect the workbook strcuture<br>
.Application.ActiveWorkbook.Protect
"xxx",
Structure:=True, Windows:=False<br>
<br>
'Password protect the file [OnOpen
password]<br>
.Application.DisplayAlerts = False<br>
.Application.ActiveWorkbook.SaveAs
FileName:=sFile,
Password:="xxx", WriteResPassword:="xxx"<br>
.Application.DisplayAlerts = True<br>
<br>
.Application.ActiveWorkbook.Save<br>
.Application.ActiveWorkbook.Close<br>
.Quit<br>
<br>
End With<br>
<br>
Set xlApp = Nothing<br>
Set xlSheet = Nothing<br>
<br>
Exit_Testing:<br>
Exit Sub<br>
<br>
Err_Testing:<br>
MsgBox Err.Number & " - " &
Err.Description<br>
Resume Exit_Testing<br>
End Sub</font></tt>
<br>
<br><font size=2 face="sans-serif">Im****t Code (not working OK):</font>
<br>
<br><font size=2 face="sans-serif">Public Sub Im****tProtected(strFile As
String, strPassword As String)<br>
Dim oExcel As Object, oWb As Object<br>
Set oExcel = CreateObject("Excel.Application")<br>
Set oWb = oExcel.Workbooks.Open(FileName:=strFile,
Password:=strPassword)<br>
DoCmd.TransferSpreadsheet acIm****t, acSpreadsheetTypeExcel9,
"Im****t",
strFile, -1<br>
oWb.Close SaveChanges:=False<br>
oExcel.Quit<br>
Set oExcel = Nothing<br>
End Sub </font>
<br>
<br><font size=2 face="sans-serif">Can someone help me on this issue or
inform me on how I can ex****t the data in another way and keep the data
hidden?</font>
<br>
<br><font size=2 face="sans-serif">Regards,</font>
<br><font size=2 face="sans-serif">Peter</font>
--=_alternative 005EFF76C1257495_=--


|