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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting VB macro to executable 1

Status
Not open for further replies.

Faydrus

Technical User
Jan 5, 2005
3
US
Got a question ladies and gents.
Been writing a macro for a colleague to extract BUS data and display onto an excel template...
Eventuallly got there and now decided to make an executable out of it..
YEs i have included the Excel references and everything works, though painfully slow compared to the macro
except the adding of textboxes oif varying dimensions..

ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 351.75 + (Byte_Data(Counter, reference, 1) * Template_Width_PerByte), 170.25 + (Counter * Template_Height_PerRow), (Byte_Data(Counter, reference, 0) * Template_Width_PerByte), (Template_Height_PerRow)).Select

I'm getting error 1004 - value out of range!!

Admittedly the code is obscure, but any ideas why it would work in a macro and not as an executable??
Regards
Peter I
 
Hi Faydrus,

I can't answer your question at the moment and will probably just show up my ignorance, but ..

(a) Do you mean VB or VBA? If VB, how are you running the macro?
(b) How exactly have you created your executable? And how are you running it?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Thanx Tony,
your questions makes me wonder if my problem is a setup one...

Answer : I don't know!!

The macro was written within Excel, as I was teaching myself VBA(I guess).

As an exercise I decided to try and produce an .exe from my macro code using VB6

So I've basically got a blank form with a big 'start' button that just loops straight into cut/pasted VBA code.

Is there any fundamental differences between accessing graphics from VB or VBA??

Cheers Mate
 
Hi Faydrus,

I'm not well up on VB so I get a further chance to display my ignorance.

VBA is Visual Basic for Applications. It is a language designed to run within a host application and it can use the Properties and Methods of that application.

VB (Visual Basic) is the same language as VBA but it runs stand-alone and does not have a host application. To make it instantiate and/or communicate with an application you must write extra code and I'm not going to cover that directly here.

To use a VB-written executable in a host Office Application such as Excel, you must write it as a COM AddIn. This Microsoft Web Page should get you started,

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Don't you write it (in VB) as a ActiveX DLL? Which translates (in the application) as a COM Addin?

Hard to say without seeing the whole code, but I know one thing....cut and paste from VBA into VB is NOT a flawless process.

Are you sure you have all references covered?
Are you sure all your variables are declared properly?
Did you test it before you actually compiled it?

Gerry
 
THANX ALL...

It appears to be working now, by adding extra references to General MSOFfice and MSGraph 8.0

My god is it slow though, so I'm thinking your advice is porobabkly correct and I have gone about this in a rather ad hoc fashion by writing as an .exe.

Cheers, this has been my first foray into the wolrd of forums...

Don't work to hard...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top