Morten Bo Johansen wrote:
Hi all,

I have recorded a simple macro that saves the current sheet(s) as an HTML
file. My problem is that I do not know how to subsitute the file name in
the macro with a generic modifier for the file name of the current sheet.
The pertinent part of the macro looks like this:

  [snip]
sub save_as_html
  rem ----------------------------------------------------------------------
  rem define variables
  dim document   as object
  dim dispatcher as object
  rem ----------------------------------------------------------------------
  rem get access to the document
  document   = ThisComponent.CurrentController.Frame
  dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
  dim args1(2) as new com.sun.star.beans.PropertyValue
  args1(0).Name = "URL"
  args1(0).Value = "file:///home/mojo/Desktop/bridge-uge.html"
  args1(1).Name = "FilterName"
  args1(1).Value = "HTML (StarCalc)"
  args1(2).Name = "SelectionOnly"
  args1(2).Value = true
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args1())

The problem with this is that whenever I execute the macro, the saved
html-file will always be called "bridge-uge.html", whereas I want it to
have the name of whatever the name of the current sheet is.

How do I substitute the value of this line

  args1(0).Value = "file:///home/mojo/Desktop/bridge-uge.html"

with a modifier that attains my object?


Thanks,

Morten
Hi, Morten

You need to insert something like the following before your line defining the dispatcher ( dispatcher = etc ) (in StarBasic a colon substitutes as a line break, enabling you to insert new code on the same line):

oDoc = ThisComponent : oSheet = oDoc.getCurrentController.ActiveSheet
sSheetName = oSheet.getName : sPath = "file:///home/mojo/Desktop/"
sUrl = sPath & sSheetName & ".html"  ' : Msgbox sUrl

Then, replace the present flag defining the value of "Url" with:

args1(0).Value = sUrl

You could replace the use of the dispatcher with StarBasic code, if you have any interest in doing so.

An alternative to parts of the above is:

sPath = "/home/mojo/Desktop" : sUrl = ConvertToUrl( sPath & sSheetName & ".html" )


--

If you're seeking, check out http://www.rci.org.au

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to