• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 467
  • Last Modified:

C or VC++

Do any of you know how to write code in c or vc++ to disable password protected excel files? We want to automate this process. I know how we can disable it manually. We are looking to automate the process for reading excel file with password protections on them.
I have a VB script  that works fine but can anyone help with similar script to VB but in C or VC++.  
Sample VB script code was supplied by Genius<
this code removes the password

Dim xlApp, xlWb

Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Open("c:\folder\subfolder\foo.xls", , , , "the_password")
xlWb.Password = ""
xlWb.Save
xlWb.Close
Set xlWb = Nothing
Set xlApp = Nothing

To reapply the password, put this in a *.vbs file:

'this code applies the password

Dim xlApp, xlWb

Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Open("c:\folder\subfolder\foo.xls")
xlWb.Password = "the_password"
xlWb.Save
xlWb.Close
Set xlWb = Nothing
Set xlApp = Nothing
0
SuperFly07
Asked:
SuperFly07
1 Solution
 
NorbertCommented:
I would suggest to stay with VB
Doing the same with C++ would not be impossible but a lot of work.
If you are using Visual Studio that can help you by defining classes to acces the excel
You have to define an ATL classes to manage the all the  dispatch interfacees you need.
and what a simple assign is in VB vill be a function call into the specific dispatch interface in c++

VB is much easier do handle such things
0
 
inthedarkCommented:
Would agree stay with VB or use C#.net
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now