run a VBA macro from command line

F

francky

hi all,
I am devlopping a program java which has to call a VBA macro.
I guess there is a way to use Runtime.exec so I can call the macro from
a command line.
the problem is, I know how to call my VBA macro from command line.

Could someone helps me?

Thnak you
 
Z

zz

couldn't you instead of using the macro call a VBScript routine that does
the same stuff that the macro?
 
F

francky

Rewrite it in either VB or VBS.

hi I am trying what you did tell me.
in fact the proplem is this:
I have some Excel file that I sent to people and i am oblige to keep
one atandard format. I therefore protect them to avoid any mess with my
standard format.
once they send me back the file I go though that using odbc link in a
java application but hit doesnt like the protection. So I decided to do
un VB code unprotect the file so I can call it using the .exe

I am not familiar with Vb i am a java developper.
Can you tell me why my VB doesn't work because of this like?

Dim isFileExist As Boolean
isFileExist = My.Computer.FileSystem.FileExists(sBookAProteger)

I got one error said object required

thanks in advance
 
K

Karl E. Peterson

francky said:
hi I am trying what you did tell me.
in fact the proplem is this:
I have some Excel file that I sent to people and i am oblige to keep
one atandard format. I therefore protect them to avoid any mess with
my standard format.
once they send me back the file I go though that using odbc link in a
java application but hit doesnt like the protection. So I decided to
do un VB code unprotect the file so I can call it using the .exe

I am not familiar with Vb i am a java developper.
Can you tell me why my VB doesn't work because of this like?

Dim isFileExist As Boolean
isFileExist = My.Computer.FileSystem.FileExists(sBookAProteger)

I got one error said object required

Uhhh... That wouldn't be VB, actually. Looks more like Visual Fred.
 
F

francky

I
you rigth I mess up with .NET
I finally find a solution I make a .exe with VB which is able to
unprotect the file and then I call the .exe in java code by using the
runtime class.

here is the snippet to unprotect.

If Dir(sBookAProteger) <> "" Then
Dim xlApp As Excel.Application
Dim xlBook As Workbook
Dim i As Integer

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(sBookAProteger)
For i = 1 To xlBook.Sheets.Count
If xlBook.Sheets(i).Name = sFeuilleAProteger Then

xlBook.Activate

xlBook.Sheets(sFeuilleAProteger).Select

xlBook.Worksheets(sFeuilleAProteger).Protect (vPassword)

Exit For

ElseIf i = xlBook.Sheets.Count Then
MsgBox ("La feuille à protéger n'existe pas!" = vbCritical)
End If
Next i
xlBook.Close (True)
xlApp.Quit

Set xlBook = Nothing

Set xlApp = Nothing

Else
MsgBox ("Le fichier n'existe pas!" = vbCritical)
End If

thanks again for your time
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top