Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert excel to VB6 1

Status
Not open for further replies.

AlfredSpecial

Programmer
Apr 4, 2005
161
GB
Hello

I have created a program in excel that uses macros etc and i was wondering if i could add it to a VB project so i could protect it.

Is this possible?
 
Alfred:

Very possible...I do it all the time. My question is do you want to keep this as a VBA application, or a VB6 executable? (VBA can only be run within Excel). Even if you use it as a VBA project, you can protect it by right clicking on the VBA project in the VBE (Visual Basic Editor) and choose VBAProject Properties. Here you can password protect your project to keep others from messing with the code.

Let me know.

Ron

Ron Repp
 
Hi Ron,

What i want to do is really run my excel application from within VB6 so i can make it look nicer and i will also be able to give it a login password that is not easy to hack.

If i was to start again and only use VB6 i would need a way i could cut and paste text from an excel spreadsheet into my application.For example if i cut say A1 to A100 i would want this in my VB application in textboxA1 to A100 but in textboxB1 to B100 it would have the same data but with a prefix...

does this make sense

thanks

Alfred
 


You'll need to use the GetObject method to instantiate the Excel application.workbook object. Check out VB Help example.


Skip,

[glasses] [red]Be Advised![/red]
A wee deranged psychic may be runnin' around out there!
SMALL MEDUIM @ LARGE[tongue]
 
>a login password that is not easy to hack

Latest versions of Office (2000/2003) have pretty secure passwords. It was the old Office 97 that was sadly pathetic in this regard (read the small print in many of the password recovery sites)
 
Alfred:

To do what you want (cut & paste cell values) is way beyond the scope of these forums. Skip is correct, study up on the CreateObject/GetObject functions OR (and here is where all the programmers cringe) set a reference to Excel within your VB6 app and use the the Excel.Application object. I never use CreateObject, though it is more standard, and I've done thousands of unattended apps and GUIs using VB6 and Excel. However, by using the Application object, you get Intellisense to help you through the remaining Excel objects (i.e. Workbooks, Cells,...)

StrongM is also correct. The newer versions of MS Office are extremely difficult to hack, depending on the password. However, this being said, if somebody really wants to get into your application, they'll do it.

Once you are comfortable with what can/cannot be done within your VB6 application, cut and paste your VBA code and use them as procedures/fuctions within the VB6 application and use Excel as your output tool

Here's a snippet:

=========================
Dim XL as Excel.Application
Set XL = New Excel.Application

Dim c

''This will add the values in A1-A100 into your textbox, providing you have your Multiline value set to true.

For each c in XL.Activesheet.Range("A1:A100")
c.activate
Text1.Text = Text1.Text & XL.Activecell.Value & vbCRLF
Next
==========================

I hope this helps and doesn't confuse you too much.

Ron




Ron Repp
 
> way beyond the scope of these forums

Eh?

>here is where all the programmers cringe

Eh?

>CreateObject, though it is more standard

Eh?

 
Alfred - do a search on this forum using Excel as your search string. The question has been answered several times

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Tyson:

That was a great article. Thanks for sharing.

Ron

Ron Repp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top