[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • 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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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