Script Help

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Script Help

Craig Johnson
I need a little help with a script….

I need this script to ask me where to save an excel file that is being
exported from SPSS.  I was given the following code which works
however all it asks me is what to call the file while it defaults to
saving the file in "My Documents."  I need the script to ask me what
to call the file and where to save it through the standard browse
button.

Sub Macro1()
' Macro recorded 27/08/2007
Dim filespecs As String

       filespecs = InputBox("file specs?")
       With objExcelApp
   .ActiveWorkbook.SaveAs Filename:=filespecs, _
       Password:="", WriteResPassword:="", _
       ReadOnlyRecommended:=False, CreateBackup:=False
   End With
End Sub

I have found the following code for how it is done in excel and
thought someone might know how to pull this off in SPSS
scripting…….any help would be appreciated.

Sub SaveIt()
Dim ck As Boolean
' SaveIt Macro
' Macro developed 11/6/2001 by Rick E
If newName = "" Then
str1 = "Enter New File Name Here"
Else
str1 = newName
End If
ck = Application.Dialogs(xlDialogSaveAs).Show(str1)
If ck = True Then
newName = ActiveWorkbook.Name
End If
End Sub

Thanks,

Craig
Reply | Threaded
Open this post in threaded view
|

Re: Script Help

Peck, Jon
You might find it useful to look at the script on the Downloads section of SPSS Developer Central (www.spss.com/devcentral) called Excel Export.  It does the saving on the SPSS side, not the Excel side, but it does put up a dialog for you to enter the location of the file as well as having some other useful features.

HTH,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Craig Johnson
Sent: Monday, August 27, 2007 8:44 PM
To: [hidden email]
Subject: [SPSSX-L] Script Help

I need a little help with a script….

I need this script to ask me where to save an excel file that is being
exported from SPSS.  I was given the following code which works
however all it asks me is what to call the file while it defaults to
saving the file in "My Documents."  I need the script to ask me what
to call the file and where to save it through the standard browse
button.

Sub Macro1()
' Macro recorded 27/08/2007
Dim filespecs As String

       filespecs = InputBox("file specs?")
       With objExcelApp
   .ActiveWorkbook.SaveAs Filename:=filespecs, _
       Password:="", WriteResPassword:="", _
       ReadOnlyRecommended:=False, CreateBackup:=False
   End With
End Sub

I have found the following code for how it is done in excel and
thought someone might know how to pull this off in SPSS
scripting…….any help would be appreciated.

Sub SaveIt()
Dim ck As Boolean
' SaveIt Macro
' Macro developed 11/6/2001 by Rick E
If newName = "" Then
str1 = "Enter New File Name Here"
Else
str1 = newName
End If
ck = Application.Dialogs(xlDialogSaveAs).Show(str1)
If ck = True Then
newName = ActiveWorkbook.Name
End If
End Sub

Thanks,

Craig