![]() |
how can I open a password protected document through vb?
I am using the GetObject(filename) command to open up an excel spreadsheet
from a VB program. The excel spreadsheet opens up but it is requesting the password and the writerespassword. How can I supply them through code so that the user never sees this? Many Thanks June |
how can I open a password protected document through vb?
I don't speak the VB, but this worked ok for me in word:
Option Explicit Sub testme01() Dim oExcel Dim oWorkBook Dim xlWasRunning As Boolean xlWasRunning = True On Error Resume Next Set oExcel = GetObject(, "Excel.Application") If Err Then Set oExcel = CreateObject("Excel.Application") xlWasRunning = False End If oExcel.Visible = True Set oWorkBook = oExcel.Workbooks.Open("C:\my documents\excel\book10.XLS", _ Password:="a", WriteResPassword:="b") 'do stuff oWorkBook.Close False Set oWorkBook = Nothing If xlWasRunning Then 'do nothing Else oExcel.Quit Set oExcel = Nothing End If End Sub June Macleod wrote: I am using the GetObject(filename) command to open up an excel spreadsheet from a VB program. The excel spreadsheet opens up but it is requesting the password and the writerespassword. How can I supply them through code so that the user never sees this? Many Thanks June -- Dave Peterson |
All times are GMT +1. The time now is 02:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com