Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
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.
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
You're the Man!