PDA

View Full Version : can we create .exe file for Macros which we have created



nishant
03-08-2006, 07:22 AM
I have created a form which consist of one button, when button is clicked some macro code is getting run. whenever I want to run that form I need to open a word document and need to open a Visual Basic editor and run the same. Can't I create a .exe file similar to what we do in visual basic by using make.

One thing More,

Dim word as Document when used in Macro code works fine but when same thing When i use in VB it gives error that

"user defined data type not defined"

Please Help me out.:banghead:

Killian
03-08-2006, 07:48 AM
Hi and welcome to VBAX :hi:

It is not possible to create an exe file in VBA, but that's OK because you probably don't need to.
Instead of using a userform with one button, you could use a custom toolbar that runs the macro.
Note: The best way to do this depends on which application you are using and whether you need to distrubte your code to other users, but to start with, go to Tools>Customize... (in the host application), make a new toolbar, then add a command button from the the list of macros available.

Regarding "Dim word as Document"

"Document" is a data type in the Word Object Model. If you are using Word from another application and have added a reference to Word (VBE>Tools>References) then you should refer to it explicitly through the object modelDim appWd As Word.Application
Dim docSource As Word.Document


' create a new instance of Word
Set appWd = New Word.Application
' open a document
Set docSource = appWd.Documents.Open(filepath)
appWd.Visible = Trueor if you have not set a reference (late-binding), they will need to be ObjectsDim appWd As Object
Dim docSource As Object


' create a new instance of Word
Set appWd = CreateObject("Word.Application")
' etc...Hope that helps...