Highlighted
Super Contributor.. Super Contributor..
Super Contributor..
613 views

Button to create CSV file

I've been given a task to create a button function in the Requirements module to produce a .CSV file of all the requirements. On the outset, I told them the easiest was to create the file via the Analysis module in Excel, but I was out voted.

So, I have the SQL query, I have the button and the button does open Notepad. How do I get the SQL query results into notepad?

0 Likes
3 Replies
Highlighted
Honored Contributor.
Honored Contributor.

You can try with command object or try with requirement and other objects

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Do you mind sharing what code or script you used?

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

This is a pretty old post, but it seems like you still need it.

 

If you have added a working button, then add the following to the ActionCanExecute function, of course renaming the ActionName to whatever you named your button action.

  if ActionName = "UserDefinedActions.Requirements_ExportCSV" Then
     Set WSS = CreateObject("WScript.Shell")            'only needed if you're saving to Desktop
     DesktopFldr = WSS.SpecialFolders("Desktop")        'only needed if you're saving to Desktop
     OutputFile =  DesktopFldr & "\Sample.csv"

     Set FSO = CreateObject("Scripting.FileSystemObject")
     Set CSV = FSO.CreateTextFile(OutputFile, true)
'     CSV.WriteLine("Sample,1,2,3")     'Write just one line at a time, usually inside a loop
     CSV.Write("Sample,1,2,3" & vbCRLF & "NewLine,4,5,6")   'Write an entire file in one shot, use vbCRLF between lines
     CSV.Close
     Set FSO = Nothing
     msgbox "should have created as " & OutputFile
  End if
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.