Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception to password-protected document meems Excel Discussion (Misc queries) 1 May 12th 10 04:29 PM
Password protected document with new level of security for Office ego Excel Discussion (Misc queries) 0 February 19th 09 05:33 PM
I forgot my password to open an excel document, how do I open it? chris ohearn Excel Discussion (Misc queries) 1 August 11th 08 02:32 PM
Linking to a Password Protected Document in Excel 2000 Andrew Excel Discussion (Misc queries) 2 February 15th 05 01:06 AM
Open password protected workbook. Tom Excel Programming 3 April 16th 04 03:43 PM


All times are GMT +1. The time now is 08:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"