Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18011
Number of posts: 55384

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Opening excel files Posted by Cory on 28 Feb 2006 at 10:52 PM
I need to find code that will open up an excel file that has a password, and let a user edit it. I don't want VB to do anything except actually launch excel by means of shell or something similiar, and have the password automatically entered. Any suggestions would be appreciated.
Report
Re: Opening excel files Posted by lionb on 1 Mar 2006 at 7:32 AM
: I need to find code that will open up an excel file that has a password, and let a user edit it. I don't want VB to do anything except actually launch excel by means of shell or something similiar, and have the password automatically entered. Any suggestions would be appreciated.
:
Not sure but you may try sometjing like this
    Dim objExcel As Excel.Application
    Dim objWorkBook As Workbook
    Dim strPasword As String
    strPassword = InputBox("Please Enter Password", "Password")
    Set objExcel = CreateObject("EXCEL.APPLICATION")
    Set objWorkBook = objExcel.Workbooks.Open("C:\Test\test2.xls", , , , strPassword)' Check for password
    objWorkBook.SaveAs ("C:\Test\test3.xls")
    objWorkBook.Close
    Set objWorkBook = Nothing
    objExcel.Quit
    Set objExcel = Nothing

Report
Re: Opening excel files Posted by Cory on 2 Mar 2006 at 2:10 PM
I have the following:

Dim objExcel As Excel.Application
    Dim objWorkBook As Workbook
    Dim strPasword As String
    Set objExcel = CreateObject("EXCEL.APPLICATION")
    Set objWorkBook = objExcel.Workbooks.Open("C:\Intake\Excel Template\template_excel.xls", , , , "mypassword") ' Check for password


This does open the file, however, I dont wish to edit anything in VB, only use VB to open the excel sheet. After that, I need for the Excel sheet to remain open and editable manually by the user




: : I need to find code that will open up an excel file that has a password, and let a user edit it. I don't want VB to do anything except actually launch excel by means of shell or something similiar, and have the password automatically entered. Any suggestions would be appreciated.
: :
: Not sure but you may try sometjing like this
:
:     Dim objExcel As Excel.Application
:     Dim objWorkBook As Workbook
:     Dim strPasword As String
:     strPassword = InputBox("Please Enter Password", "Password")
:     Set objExcel = CreateObject("EXCEL.APPLICATION")
:     Set objWorkBook = objExcel.Workbooks.Open("C:\Test\test2.xls", , , , strPassword)' Check for password
:     objWorkBook.SaveAs ("C:\Test\test3.xls")
:     objWorkBook.Close
:     Set objWorkBook = Nothing
:     objExcel.Quit
:     Set objExcel = Nothing
: 

:

Report
Re: Opening excel files Posted by lionb on 3 Mar 2006 at 5:30 AM
: I have the following:
:
:
: Dim objExcel As Excel.Application
:     Dim objWorkBook As Workbook
:     Dim strPasword As String
:     Set objExcel = CreateObject("EXCEL.APPLICATION")
:     Set objWorkBook = objExcel.Workbooks.Open("C:\Intake\Excel Template\template_excel.xls", , , , "mypassword") ' Check for password
      objWorkBook.Visible = True
: 

:
: This does open the file, however, I dont wish to edit anything in VB, only use VB to open the excel sheet. After that, I need for the Excel sheet to remain open and editable manually by the user
:
To do that add line off code colored as blue to your code. It will be also good to have code like that somewere, may be in Form Unload event
 Set objWorkBook = Nothing
 objExcel.Quit
 Set objExcel = Nothing


Report
Re: Opening excel files Posted by Cory on 3 Mar 2006 at 9:47 AM
It works, but I need to change the blue code, I believe it should be

objExcel.Visible = True


Thanks for the help

: : I have the following:
: :
: :
: : Dim objExcel As Excel.Application
: :     Dim objWorkBook As Workbook
: :     Dim strPasword As String
: :     Set objExcel = CreateObject("EXCEL.APPLICATION")
: :     Set objWorkBook = objExcel.Workbooks.Open("C:\Intake\Excel Template\template_excel.xls", , , , "mypassword") ' Check for password
:       objWorkBook.Visible = True
: : 

: :
: : This does open the file, however, I dont wish to edit anything in VB, only use VB to open the excel sheet. After that, I need for the Excel sheet to remain open and editable manually by the user
: :
: To do that add line off code colored as blue to your code. It will be also good to have code like that somewere, may be in Form Unload event
:
:  Set objWorkBook = Nothing
:  objExcel.Quit
:  Set objExcel = Nothing
: 

:
:

Report
Re: Opening excel files Posted by lionb on 3 Mar 2006 at 10:49 AM
: It works, but I need to change the blue code, I believe it should be
:
:
: objExcel.Visible = True
: 

:
Yes. That's right.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.