Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
m_woolf
Master II
Master II

Macro to set Listbox Font Name

This macro works fine unless the FontName contains a Space. Any ideas?

sub SetFont

set val=ActiveDocument.Fields("FontName").GetSelectedValues

strFontName = val.Item(0).Text

set mybox = ActiveDocument.GetSheetObject("LB02")

mbp = mybox.GetProperties

mbp.Layout.Frame.Font.FontName = strFontName

mbp.Layout.Frame.Font.Bold = false

mbp.Layout.Frame.Font.Italic = false

mbp.Layout.Frame.Font.Underline = false

mybox.SetProperties mbp

end sub

1 Solution

Accepted Solutions
marcus_sommer

I assume that your source is copied from any html-source and is messed with a "non-standard" white-space and needs to be cleaned with something like this:

strFontName = replace(strFontName, chr(160), chr(32))

- Marcus

View solution in original post

4 Replies
marcus_sommer

If I use the follwing it worked:

sub SetFont

'set val=ActiveDocument.Fields("FontName").GetSelectedValues

strFontName = "Courier New" ' "Arial Baltic" 'val.Item(0).Text

set mybox = ActiveDocument.GetSheetObject("LB23")

mbp = mybox.GetProperties

mbp.Layout.Frame.Font.FontName = strFontName

mbp.Layout.Frame.Font.Bold = false

mbp.Layout.Frame.Font.Italic = false

mbp.Layout.Frame.Font.Underline = false

mybox.SetProperties mbp

end sub

or did you mean something different?

- Marcus

m_woolf
Master II
Master II
Author

Marcus,

Thanks for your reply. Yes, it works if I hard code "Courier New" in the vbscript. But when I read the FontName from data, it doesn't work.

I attached a sample QVW.

marcus_sommer

I assume that your source is copied from any html-source and is messed with a "non-standard" white-space and needs to be cleaned with something like this:

strFontName = replace(strFontName, chr(160), chr(32))

- Marcus

m_woolf
Master II
Master II
Author

You're the Man!