Consulting

Results 1 to 18 of 18

Thread: square box with question mark symbol

  1. #1

    Smile square box with question mark symbol

    I am using Word VBA to create a word template.

    I have a multi-line text box. When I save the contents of the textbox to a document variable and insert the document variable into the word document I get a funny symbol "square box with a question mark inside". I cannot use words find and replace feature to get rid of the symbol. I tryied to paste the symbol into the words replace box but that did not work, since the symbol appears to be unkown to word. If I paste the contents of the text box directly into the document (not using a document variable) then I do not get the symbol. However, I need to insert the text using document variables.

    Please help.

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    "However, I need to insert the text using document variables. "

    Why?

  3. #3

    Why I need document variables

    I need to use document variables, since these are inserted in many places in the document (boiler plate type). I need the user to be able to enter text in a text box and update the document variables everywhere in the entire document. I cannot copy/paste since that would require i find each occurance of the particilar text. For example, I have a document variable for client name, cost, introduction, report methodology etc.. So when they click on the update button, all the document info is updated.

    I discovered that the square box is Char(13) or Char(10). Therefore I need a way to search the entire document and replace the Char(10) and Char(13) with " ".

    Any thoughts?

  4. #4
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    Your template is corrupt.

    The only way I've been able to make the boxes go away is to export all the modules/userforms and start over with a fresh template, then import.

    Good luck.

    ---------
    Disregard, I'm thinking about formfields.
    Last edited by Tinbendr; 06-10-2010 at 05:04 AM.

    David


  5. #5

    Thumbs up Fix for square box with question mark symbol

    I discovered a way to search for the Char(10) symbol and replace it with " ".
    -------------------------------------
    Public Sub ReplaceChar10()
    ' When you write a multi-line textbox to a document variable new lines are
    ' preceeded by Char(10). In Times, or Arial this shows up as a small square.
    ' In Calibri it shows up as a square box with a question mark inside.
    ' The following function searches the entire document for Char(10) and replaces it with ""
    Selection.find.ClearFormatting
    Selection.find.Replacement.ClearFormatting
    With Selection.find
    .text = "^010"
    .Replacement.text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.find.Execute Replace:=wdReplaceAll
    End Sub

  6. #6
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    If you replace Line Feed characters with nothing ("") you are removing them from the input? Is this what the user wants - all the lines of input run together?
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  7. #7

    replace Line Feed characters with nothing ("")

    From Tony: If you replace Line Feed characters with nothing ("") you are removing them from the input? Is this what the user wants - all the lines of input run together?

    In fact, the Char(10) that I am replacing appears at the beginning of a new line at the end of a paragraph containing the document variable text. So replacing with (" ") gets rid of Char(10) but does not cause the the lines of paragraphs run together.

    However, there appears to be two spaces between paragraphs since the Char(10) is replaced with a (" ") and appears on the last line. Then it is followed by the normal paragraph break (^p).

    I would prefer to delete the line that Char(10) appears on all together instead of replacing it with (" ")

    Any thoughts?

  8. #8
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Why not clear it out before it ever gets to Word?

    If you are putting the text in a doucmnet variable, do it this way ..

    [VBA]ActiveDocument.Variables("VarName") = Replace(TextboxName.Text, vbCrlf, vbCr)[/VBA]
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  9. #9
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    I need the user to be able to enter text in a text box and update the document variables everywhere in the entire document. I cannot copy/paste since that would require i find each occurance of the particilar text. For example, I have a document variable for client name, cost, introduction, report methodology etc.. So when they click on the update button, all the document info is updated.
    You do NOT need to use DOCVARIABLES to do this. You do NOT need to do a copy/paste either.

    Demo attached. The userform is displayed on document open. Put text into the textbox, using Shift-Enter to put multiple lines. Click the commandbutton.

    1. the text from the textbox goes to its indicated location.
    2. there is no square box
    3. the text is duplicated in multiple locations

    No document variables used.

    I am not saying using doc variables is wrong. I am saying that "I need to use document variables" is an incorrect statement.

    You do not need to use document variables.

  10. #10
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Interesting. I just tested my posted file. It does NOT fire Document_Open. Hmmmm.

    Reposted. The userform is displayed by clicking "Show My Form" on th etop toolbar.

    I hope.

  11. #11
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Good. That works.

  12. #12
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Gerry - your doc in #9 does automatically show the Userform on open (in my "2003+4" version of Word

    Paul

  13. #13
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Nope. I just tried it again. It does work if I save the file with a TargetAs, and then open it. (Or doing a SaveAs from the attachment.php.)

    I was thinking it would fire Open just on clicking it here.

  14. #14
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Paul,

    What browser are you using?
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  15. #15
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Tony

    IE8, but I always save files to my Desktop to scan before I open them.

    Never occured to me that other people might do it differently, so I never thought to mention that.

    Gerry's doc did not fire it's Document_Open if I just tried to open it directly without first saving

    Paul

  16. #16
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Thanks, Paul - the 'problem' is something to do with IE security settings, an area I'm really trying to understand. The Open event does fire when opened from Opera and Safari (the two I tried), but not from IE even when vbaexpress is added to Trusted Sites.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  17. #17
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Ditto. It used to fire with IE 6 and IE 7.

  18. #18
    thanks

Posting Permissions

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