Results 1 to 7 of 7

Thread: [RESOLVED] Stop form opening from saved word doc

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    2

    Resolved [RESOLVED] Stop form opening from saved word doc

    Hi,

    I am new to VB and as part of a larger project I've created a word template that uses a form to input text to bookmarked positions within the document. I have also added a macro to Save As and enforce a naming protocol on users. The idea being that users can search for and open a document using a "project number" as a reference.

    Both the template and the saved and named files are opened via an Excel master document.

    My question is how do I stop the form I created for the template appearing when a saved file is opened?

    Any advise will be very much appreciated.

  2. #2
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Stop form opening from saved word doc



    yourformName.hide

    or

    me.hide

    To show your form again

    me.show

    and

    You have to unload it properly once your work is completed
    CS

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Stop form opening from saved word doc

    Moved to Office Development

  4. #4
    Lively Member New2vba's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    95

    Re: Stop form opening from saved word doc

    I'm guessing, but from your description, it sounds like you userform is being initialised by the open event?

    If this is the case, then I assume your "template" is in-fact a document (.doc) that you are using as a template rather than a true template (.dot)?

    If the above assumptions are correct, then convert your document to a template (.dot) and initialise your userform from the new event. Then when a document (.doc) is saved from the template, opening the saved document later will not initialise your userform.

    Incidentally, I am interested in enforcing filename conventions to some templates I have. Can you provide sample code to show how you are achieving this?
    "Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    2

    Re: Stop form opening from saved word doc

    That's great - works perfectly, Thanks!

    I've cheated with the enforced file naming by using a "project number" as a reference for a range of documents.

    VB Code:
    1. Dim PathAndFileName As String
    2. Dim ProjNo As String
    3. ProjNo = frmProjNo.txtProjNo.Value
    4. PathAndFileName = "C:\[I]filepathandname[/I] "
    5. ActiveDocument.SaveAs (PathAndFileName & ProjNo & ".doc")

    It's very basic but hey I'm new at this!
    Last edited by Hack; May 15th, 2006 at 01:38 PM. Reason: Fixed [vbcode] [/vbcode] tags

  6. #6
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Stop form opening from saved word doc

    Please use [vbcode] your code goes in here [/vbcode] tags when posting code.

    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    CS

  7. #7
    Lively Member New2vba's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    95

    Re: Stop form opening from saved word doc

    Quote Originally Posted by ipollasa
    That's great - works perfectly, Thanks!

    I've cheated with the enforced file naming by using a "project number" as a reference for a range of documents.
    VB Code:
    1. Dim PathAndFileName As String
    2. Dim ProjNo As String
    3. ProjNo = frmProjNo.txtProjNo.Value
    4. PathAndFileName = "C:\[I]filepathandname[/I] "
    5. ActiveDocument.SaveAs (PathAndFileName & ProjNo & ".doc")
    It's very basic but hey I'm new at this!
    Not quite what I was looking for, but thanks anyway
    "Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )

Posting Permissions

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



Click Here to Expand Forum to Full Width