Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Feb 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to hide control bars from Word (Word 2000)

    Hi guys,

    I'm trying to remove all the control bars from Word, and I started doing some testing:

    Dim pApp As Word.Application
    Dim pDoc As Word.Document
    Dim Total As Integer

    pDoc = CreateObject("Word.Document")
    pApp = pDoc.Application

    Total = pApp.CommandBars.Count << It crashes saying 'Library not registered'

    Any ideas why I get this error?

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How to hide control bars from Word (Word 2000)

    Welcome to Woody's Lounge!

    In which application are you trying to run this code?

    Since pDoc and pApp are object variables, you must use Set to assign them:

    Set pDoc = ...
    Set pApp = ...

  3. #3
    New Lounger
    Join Date
    Feb 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to hide control bars from Word (Word 2000)

    Hi HansV,

    I'm a old member from this forum, but I haven't been here in a long long time... so long that I forgot my username and password and had to register again [img]/forums/images/smilies/smile.gif[/img]

    I'm using Visual Studio 2005 and VB.
    VS2005 removes the 'set' command automatically while you are typing.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How to hide control bars from Word (Word 2000)

    I have no experience at all with Visual Studio 2005. Sorry.

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: How to hide control bars from Word (Word 2000)

    I am also not familiar with Visual Studio 2005.

    I took your code, added the SET to the beginnings of the two lines
    <code> Set pDoc = CreateObject("Word.Document")
    Set pApp = pDoc.Application
    and ran it from within VBA with no errors.</code>


    I had a quick look at Getting Started (Visual Studio Tools for Office) and there's clearly a lot of work to do to get this working. Do you have any other Office Automation projects that work correctly in Visual Studio?

    StuartR

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: How to hide control bars from Word (Word 2000)

    Hi,
    AFAIK, you need an Office Interop Assembly to do this. Unfortunately, MS has only released these for Office XP and 2003, but you can work around this according to this article. It references Excel but the principle should be the same for Word.
    Hope that helps a bit.
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    New Lounger
    Join Date
    Feb 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to hide control bars from Word (Word 2000)

    Thanks guys. I'll have a look.

Posting Permissions

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