Running SPSS-Syntax using Excel VBA (Excel 2013)

Jan 29, 2009
Reaction score

I'm using VBA to run a syntax-command in SPSS.
This is working just fine in Excel 2007, in Excel 2013 however it is not working.

This is the code I use in Excel 2007:

syntaxtext1="freq q1." 'only an example

Set ObjSpssApp = GetObject(, "Spss.Application")
On Error Resume Next

' **** if I want to create a new Output Document:
If Cells(34, 7).Value = "yes" Then
Set ObjOutputDoc = ObjSpssApp.NewOutputDoc
End If

ObjOutputDoc.Visible = True
ObjOutputDoc.Designated = True
'Application.Wait (Now + TimeValue("0:00:01"))
StrCommand = syntaxtext1

Application.DisplayAlerts = False
'Application.Wait (Now + TimeValue("0:00:01"))
ObjSpssApp.Alerts = False

' ***** run command in SPSS
ObjSpssApp.ExecuteCommands StrCommand, True

ObjSpssApp.Alerts = True
Application.DisplayAlerts = True

ObjOutputDoc.PromptToSave = True
Dim OutputName As String

Set ObjOutputDoc = ObjSpssApp.GetDesignatedOutputDoc

The macro is written to automatically create spss-commands (which are much more difficult than the example here) and then automatically run them in SPSS. As I said; this is working just fine with Excel 2007, just not with Excel 2013.

Does anybody has any idea, why this isn't working in Excel 2013 (and what i must do to make it work)?

Thanks a lot in advance!

P.S.: Sry for my bad english; I'm not a native Speaker...

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