Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Mount Prospect, Illinois
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PasteFace on CommandBars not quite right (2000-XP)

    I used .CopyFace and Paste on all the custom controls in a toolbar (yes, recursing through popups) to create a table in Word that I could later use to rebuild the toolbar.

    However, when I .copy from the table, and .PasteFace back again, the images seem to be changed: there's a white bar at the top, and sometimes additional shading I never put there. I think it's shrinking the image a bit.
    I'm not sure what's going on -- it should all be reversible, eh?

    Has anyone else seen this?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: PasteFace on CommandBars not quite right (2000

    I had this problem, too, when I was trying to create some kind of "backup" for my custom icons. I didn't find a solution; I think Word just doesn't really support icon-type bitmaps in the document body correctly.

    I think we recently had a thread on some API or maybe VBA methods for applying pictures from files on disk. Perhaps it goes both ways? Not very convenient compared with a single container with lots of room for free, rich text, but perhaps worth exploring.

  3. #3
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Mount Prospect, Illinois
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PasteFace on CommandBars not quite right (2000

    Thanks. Good to know I'm not just seeing a gremlin. On two machines. With different versions of Word.

    There's a KB article on using Word XP+ to set the pic without using PasteFace, but you need a foreground and a mask pic, and load the pix from separate files. Pain in the...

    I'm going to try putting my pix in an Excel spreadsheet instead, and trying to fetch/stow them that way. I seem to remember an old tool that did this from a VB conference years ago.

    I'd post code, but my boss is starting to consider this proprietary. It's not rocket science, just kind of tedious programming.

    (later...)

    Nope, round-tripping to Excel, just using the GUI interface results in these ugly icons that have had been anti-aliased to heck and back.
    Hmmm... I wonder if ClearType could be getting in my way?

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Brussels, Brussel, Belgium
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PasteFace on CommandBars not quite right (2000

    just a quick idea to explore:how about copying the entire commandbar and keep track of custom controls. you could set various properties of the copied commandbar to provide some basic form of preventing to user to tamper with them.

  5. #5
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Mount Prospect, Illinois
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PasteFace on CommandBars not quite right (2000

    That's certainly worth considering: a virgin copy of the toolbar under a different name in a different template is another nice place to store things.

    Part of my goal, though, was to create a table or spreadsheet with all of the parameters so that I could, in one swell foop [sic] update things not accessible to the GUI: tooltip text, help context ID and file.

    I decided the easiest way to build things was from scratch, so I didn't have to try to figure what things get removed, what added, etc. (which still leaves me with a dilemma for customizing things like shortcut menus, the standard toolbar, etc.), so I set everything from a table of data, including the pictures.

    Still hacking. Maybe I'll come up with a nice tool yet.

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: PasteFace on CommandBars not quite right (2000

    You could always store the binary data as a series of ascii values in your document (not sure where you'll hide it, maybe very tiny font?). If you create a new document, a New toolbar in that document, and drag a button to it, you can try this "proof of concept" code. Note that it presumes the existence of a "c:testing" directory.
    <pre>Sub PictureBinaryProofOfConcept()
    ' Insert picture data into document
    Dim cBtn As CommandBarButton, intFile As Integer, bytArray() As Byte
    Set cBtn = CommandBars("Custom 1").Controls(1)
    stdole.SavePicture cBtn.Picture, "c:testingscratch.bmp"
    stdole.SavePicture cBtn.Mask, "c:testingmask.bmp"
    intFile = FreeFile
    Open "c:testingscratch.bmp" For Binary Access Read As #intFile
    Debug.Print "Input bytes: " & LOF(intFile)
    bytArray = InputB(LOF(intFile), #intFile)
    Close #intFile
    Dim intCounter As Integer, strPict As String
    strPict = bytArray(0)
    For intCounter = 1 To UBound(bytArray)
    strPict = strPict & "-" & bytArray(intCounter)
    Next
    Selection.Font.Size = 4
    Selection.TypeText strPict & vbCrLf
    Selection.Font.Size = Selection.Style.Font.Size
    Set cBtn = Nothing
    ' Make a file and a new button
    Selection.MoveLeft unit:=wdCharacter
    Selection.MoveUp unit:=wdParagraph, Extend:=True
    Dim strArray() As String
    strArray = Split(Selection.Text, "-")
    strPict = vbNullString
    For intCounter = 0 To UBound(strArray)
    strPict = strPict & Chr(CLng(strArray(intCounter)))
    Next
    Debug.Print "Output bytes: " & Len(strPict)
    intFile = FreeFile
    Open "c:testingscratch2.bmp" For Binary Access Write As #intFile
    Put #intFile, , strPict 'tacks on extra 2 bytes...CRLF?
    Close #intFile
    Set cBtn = CommandBars("Custom 1").Controls.Add(Type:=msoControlButton)
    cBtn.Picture = stdole.StdFunctions.LoadPicture("c:testingscratch2 .bmp")
    cBtn.Mask = stdole.StdFunctions.LoadPicture("c:testingmask.bmp ")
    Set cBtn = Nothing
    End Sub</pre>

    Maybe this will help.

  7. #7
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Mount Prospect, Illinois
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PasteFace on CommandBars not quite right (2000

    Dude, that's sick. In a good way.
    Thanks. Now I know I have a fallback.
    At least they're small images, eh?

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PasteFace on CommandBars not quite right (2000

    Jefferson -
    you STILL da man!

    I'm wrestling with the problem of using an application First.dot to generate an application Second.dot, and the first application has to store images in the second.
    I got as far as First.dot building a form in Second.dot, with images on the controls, and then got stuck at the LoadPicture/SavePicture level.

    Your code will allow First.dot to pass a picture as an ascii string, as a parameter to a function in Second.dot, which function can then build the image on-the-fly, and paste it into a document.

    "Woo-", as we say in the trade, "-Wee!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •