• mvpjjf

    mvpjjf

    @mvpjjf

    Viewing 15 replies - 166 through 180 (of 208 total)
    Author
    Replies
    • in reply to: Set MS Word File Associations #1292535

      If the suggestion from JoeP517 doesn’t work, you’ll have to edit the registry entries directly. In regedit.exe, open the key
      HKEY_CLASSES_ROOTWord.Document.8shell
      Under that key, go to …Editcommand and …Opencommand (and maybe …Printcommand and …Newcommand). In each of those locations, edit the value with the name (Default) to use the full path to the Word 2003 copy of WINWORD.EXE — that is, the one in the OFFICE11 folder instead of OFFICE14.

    • Apparently the Windows program group responsible for Windows Explorer has never gotten the message that the Office team changed the file format about 5 years ago. Explorer still doesn’t have any code that look inside the XML-based docx files and retrieve custom properties from it. Peter Jamieson summed it up pretty well in his post from 2009, and nothing has changed since then.

      If you’re willing to use PowerShell (which comes with Windows Vista and Windows 7, and is available for download for Windows XP), you can use a script posted on the Hey Scripting Guy blog. Essentially, the script starts Word in an invisible window, uses it to open the document and grab the custom properties, and prints them in the PowerShell window. For general use, it would have to be modified to get the path and filename of the document you want to examine (the code in the post uses a hardcoded path and filename).

    • First, the literal answer to your question: No, there is nothing for the .Variables collection that works like the .Bookmarks.Exists() method.

      Next, let’s distinguish between a document variable (a member of the .Variables collection) and a DocVariable field that displays the value of a document variable. The document variable itself exists only in the memory space of the document, not on the document surface, so it can’t be “within a bookmark”. Your bookmark probably contains a { DocVariable varProjCost } field. The field may exist without the corresponding document variable, and vice versa.

      If a particular document variable doesn’t exist, then the only thing your code can do with it that won’t cause an error is to assign its value. If you need to do anything else when you aren’t sure whether or not the variable exists, then you need to provide an error trap — like this:

      Code:
          Dim strVal As String
          ‘ …
          On Error Resume Next
          strVal = ActiveDocument.Variables(“varProjCost”).Value
          If Err.Number = 0 Then
              MsgBox strVal
          Else
              MsgBox “Variable varProjCost does not exist”
          End If
          On Error GoTo 0  ‘ reset error handler
          ‘ …
      

      Last, there’s no harm in assigning a value to a document variable even if the DocVariable field that would display its value has been deleted from the document. It just means that there’s no display of the value, not that an error would occur.

    • in reply to: Re-examining Facebook personal privacy #1280824

      I keep my Facebook privacy set to deny permission to all applications, and I want it to stay that way.

      After going to ISharedWhat and logging into Facebook, I was prompted to grant it permission to access my profile. That prompt included this text:

      [INDENT]By clicking “Allow”, you will turn on platform applications and your “Info accessible through your friends” settings will be reset to their defaults. Learn about your privacy settings.
      [/INDENT]Absolutely not! I’ll do without ISharedWhat — and all other apps — until Facebook removes this obnoxious requirement.

    • This kind of problem happens because the macro recorder is dumber than a box of rocks. (More on this subject at http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm.) The code that results from the steps you listed is

      Code:
      Sub Macro1()
      ‘
      ‘ Macro1 Macro
      ‘
      ‘
          WordBasic.ViewFooterOnly
          ActiveDocument.AttachedTemplate.BuildingBlockEntries(“Bold Numbers 3”). _
              Insert Where:=Selection.Range, RichText:=True
          ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
      End Sub
      

      But the “Bold Numbers 3” building block isn’t in the ActiveDocument.AttachedTemplate (which is probably Normal.dotm). Instead, it’s in the Building Blocks.dotx template, which is why you’re told that the “requested member… doesn’t exist”.

      The next wrinkle is that Word doesn’t load the Building Blocks.dotx template until you ask to insert a building block or to open the Building Blocks Organizer, in order to start up faster. In a macro, we can force the template to load by calling the command Templates.LoadBuildingBlocks. Once it’s loaded, that template is usually given the first slot in the templates list, but you can never quite be sure. The cure for that is to have a function to run through the templates looking for one named “Building Blocks”.

      Finally, it isn’t necessary—in fact, it can be disruptive—to move the cursor into the footer in order to insert something there. The macro can insert the block into the footer without ever moving the cursor.

      With all that, the code you need is this (see http://www.gmayor.com/installing_macro.htm if needed):

      Code:
      Sub Macro2()
          Dim templateNum As Integer
          templateNum = GetBuildingBlocksTemplate
          If templateNum = 0 Then
              Templates.LoadBuildingBlocks
              templateNum = GetBuildingBlocksTemplate
          End If
          Templates(templateNum).BuildingBlockEntries(“Bold Numbers 3”).Insert _
              Where:=ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range, _
              RichText:=True
      End Sub
      
      Function GetBuildingBlocksTemplate() As Integer
          Dim i As Integer
          For i = 1 To Templates.Count
              If InStr(LCase(Templates(i).FullName), “building blocks”) Then
                  GetBuildingBlocksTemplate = i
                  Exit Function
              End If
          Next
          ‘ not present — return 0
          GetBuildingBlocksTemplate = 0
      End Function
      
    • The address control you’re looking for is available in the Customize Quick Access Toolbar dialog, under either All Commands or Commands Not in the Ribbon. The command name is “Document Location”.

    • in reply to: Add-ins tab in Word 2010? #1265968

      Click somewhere on the ribbon or the Quick Access Toolbar and choose Customize Ribbon. In the right-hand list in the Customize dialog, you should see the Add-Ins tab listed. If it’s there but unchecked, check it. If you want the Developer tab to appear, check that one too — it’s unchecked by default.

      And no, it was never necessary to display the Developer tab in order to see the Add-Ins tab.

    • in reply to: Find All in VBA #1197097

      Thanks for that confirmation. Maybe one day Microsoft will recognize that we need one.

      Probably the reason a Find All isn’t in VBA is that VBA also has never had any way to deal with discontiguous selections (the kind you can make with Ctrl and the mouse), which is what Find All would produce. The KB article here explains the few things that can be done. Every version since 2002 (including 2010) has made no changes in this area.

    • in reply to: 64k limit in string functions (Wd2000) #553579

      Just to nail it down… in Word 2002,

         Selection.TypeText String(65280, "a")

      and anything smaller succeeds, but

         Selection.TypeText String(65281, "a")

      and anything larger fails.

    • in reply to: Print Date in Header/Footer (Word 97/2000) #545972

      To have such a date actually in the header, you would have to make every page a separate section. This has so many drawbacks that I’d never consider it seriously.

      If you’re willing to put up with a textbox anchored in the text and placed in the header area, that might be doable. You could intercept the File/Print command with a macro that does a Dialogs(wdDialogFilePrint).Display, figures out which pages are to be printed, and inserts the current date in the textbox before saving and then printing.

      The system is likely to be “twitchy” hairy but it might work. Does this document ever get edited? What happens if that editing causes the pagination to change? (The answer to this could affect where the textbox needs to be anchored.)

    • in reply to: Print certain pages in multi-section doc (Word 2000 SR1) #545968

      Your first guess was correct: If there are two sections containing pages numbered 1-10 or more, and you ask to print 1-10, then you will get 20 pages, 10 from each section. hairout

    • in reply to: Proof Reading In Word (2000/97/XP) #1788980

      How about making your own “ruler”? Use the line tool in the Drawing toolbar to draw a line across the page, a bit wider than the text column. I like a line weight of about 1.5 pts. In the Draw menu at the left end of the toolbar, open the Grid dialog and set the vertical grid to 12 pt (for reading 10 pt TNR text). Then you can just drag the line down the page.

    • in reply to: Code help (office 2000) #545088

      I’ll add my congratulations. There’s nothing quite as encouraging as getting the censored thing to work!

      In the spirit of continuing education, I’d also like to point out that figuring out what a macro does can be very difficult when all the lines are jammed up against the left margin. For a good example plus some great suggestions, see http://www.mvps.org/word/FAQs/MacrosVBA/MaintainableCode.htm. I’d like to see your macro reposted with proper indentation.

    • in reply to: Always open in normal view (Word 2000 SR2; NT4) #545087

      I think this works in Word 97 and 2000, and for all the ways of closing a document. If you can find a situation where it doesn’t work, let me know.

      Sub AutoClose()
         With ActiveDocument
            .ActiveWindow.View.Type = wdNormalView
            .Saved = False
            .Save
         End With
      End Sub
    • in reply to: Get Name of Installed Font using API (Vb API) #545085

      3000+ fonts????

      Anything much over 1000 installed fonts makes Windows crawl on its knees snail and then fall over. puke Mostly I see recommendations to keep it down around 250, using a font manager if necessary.

    Viewing 15 replies - 166 through 180 (of 208 total)