[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.
Re: Stop form opening from saved word doc
http://www.vbforums.com/
yourformName.hide
or
me.hide
To show your form again
me.show
and
You have to unload it properly once your work is completed
Re: Stop form opening from saved word doc
Moved to Office Development
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?
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:
Dim PathAndFileName As String
Dim ProjNo As String
ProjNo = frmProjNo.txtProjNo.Value
PathAndFileName = "C:\[I]filepathandname[/I] "
ActiveDocument.SaveAs (PathAndFileName & ProjNo & ".doc")
It's very basic but hey I'm new at this!
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.
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:
Dim PathAndFileName As String
Dim ProjNo As String
ProjNo = frmProjNo.txtProjNo.Value
PathAndFileName = "C:\[I]filepathandname[/I] "
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 :thumb: