[Solved] How to open a SaveAs dialog box in calc macro
Posted: Mon Jul 21, 2008 10:32 am
I am converting an Excel Macro to Calc and I would like to know how to open a SaveAs dialog box so the user can enter a file name and file location.
As I have just started using Calc. I am not sure of the exact requirements for writing Macros. I have installed the latest SDK, I am also looking for more information on what the methods and properties are. The help in Calc is very limited compared with Excel
All the Excel code is below.
Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1
Option Explicit
Sub saveAsText()
Dim strFilename As String
Dim fName
Dim rngRow As Range
Dim fh
Dim strLine As String
Dim rngCell As Range
fName = Application.GetSaveAsFilename
If fName = False Then Exit Sub
fh = FreeFile
Open fName For Output As fh
For Each rngRow In ActiveSheet.UsedRange.Rows
strLine = ""
For Each rngCell In Intersect(rngRow, ActiveSheet.UsedRange)
If strLine <> "" Then
strLine = strLine & ","
End If
strLine = strLine & """" & CStr(rngCell.Value) & """"
Next rngCell
Print #fh, strLine
Next rngRow
Close #fh
End Sub
Thanks,
Ivan
As I have just started using Calc. I am not sure of the exact requirements for writing Macros. I have installed the latest SDK, I am also looking for more information on what the methods and properties are. The help in Calc is very limited compared with Excel
All the Excel code is below.
Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1
Option Explicit
Sub saveAsText()
Dim strFilename As String
Dim fName
Dim rngRow As Range
Dim fh
Dim strLine As String
Dim rngCell As Range
fName = Application.GetSaveAsFilename
If fName = False Then Exit Sub
fh = FreeFile
Open fName For Output As fh
For Each rngRow In ActiveSheet.UsedRange.Rows
strLine = ""
For Each rngCell In Intersect(rngRow, ActiveSheet.UsedRange)
If strLine <> "" Then
strLine = strLine & ","
End If
strLine = strLine & """" & CStr(rngCell.Value) & """"
Next rngCell
Print #fh, strLine
Next rngRow
Close #fh
End Sub
Thanks,
Ivan