AutoNew UserForm comes up before document? 
Author Message
 AutoNew UserForm comes up before document?

I am using this:

With word
    .Documents.Add Template:="\\path\template.dot"
    .Visible = True
    .ActiveDocument.SaveAs "\\path\" & name$
End With

to make a new document based on the template.  When I do this, the AutoNew
UserForm comes up *before* the text of the document. Upon close, the
UserForm returns values that are needed to modify bookmarks in the document,
but the bookmarks aren't there yet, so it errors out.

Any thoughts?



Mon, 23 Feb 2004 01:40:20 GMT  
 AutoNew UserForm comes up before document?
Hi abe,

Where are you calling this code from?

The bookmarks will need to be in the template.

I think that you will need to show us all of the code that you are using to
allow us to get a better understanding of your problem.

For instance, where does name$ come from?

Please post any response to the newsgroups for the benefit of others who may
also be following the thread.

Hope this helps,
Doug Robbins - Word MVP

Quote:
> I am using this:

> With word
>     .Documents.Add Template:="\\path\template.dot"
>     .Visible = True
>     .ActiveDocument.SaveAs "\\path\" & name$
> End With

> to make a new document based on the template.  When I do this, the AutoNew
> UserForm comes up *before* the text of the document. Upon close, the
> UserForm returns values that are needed to modify bookmarks in the
document,
> but the bookmarks aren't there yet, so it errors out.

> Any thoughts?



Mon, 23 Feb 2004 18:47:30 GMT  
 AutoNew UserForm comes up before document?
This calls a new instance of the template (which has
bookmarks in place) from Outlook:

Set word = CreateObject("word.application")
With word
    .Documents.Add
Template:="\\networkhost\path\template.dot"
    .ActiveDocument.SaveAs "\\networkhost\otherpath\" &
lastfirstdoc$    'lastfirstdoc$ is "lastname, firstname.doc"
of the contact and is valid
    .Visible = True
End With

The template has this:

Sub AutoNew()
BidGen.Show  'bidgen is the form
End Sub

When bidgen closes on an "OK" command button, it attempts to
perform many lines similar to this:

ActiveDocument.Bookmarks("StandardO").Range.Font.Hidden =
Not StandardO.Value    'there is a StandardO bookmark and a
StandardO checkbox

The template works fine if I use it from Explorer or within
Word.  The problem is that when I call it from Outlook, the
form comes up before the document is 'initiated'.  (Which
probably makes this an Outlook problem.  My apologies.)  Any
thoughts?

Thanks.
   abe



Quote:
> Hi abe,

> Where are you calling this code from?

> The bookmarks will need to be in the template.

> I think that you will need to show us all of the code that
you are using to
> allow us to get a better understanding of your problem.

> For instance, where does name$ come from?

> Please post any response to the newsgroups for the benefit
of others who may
> also be following the thread.

> Hope this helps,
> Doug Robbins - Word MVP


> > I am using this:

> > With word
> >     .Documents.Add Template:="\\path\template.dot"
> >     .Visible = True
> >     .ActiveDocument.SaveAs "\\path\" & name$
> > End With

> > to make a new document based on the template.  When I do
this, the AutoNew
> > UserForm comes up *before* the text of the document.
Upon close, the
> > UserForm returns values that are needed to modify
bookmarks in the
> document,
> > but the bookmarks aren't there yet, so it errors out.

> > Any thoughts?



Tue, 24 Feb 2004 01:18:00 GMT  
 AutoNew UserForm comes up before document?
If only I had coded:

With word
  .Visible=True
  .Documents.Add Template:="\\path\template.dot"
  .ActiveDocument.SaveAs "\\path\" & name$

in the first place.

Thanks for the assistance, Doug.

  abe


Quote:
> I am using this:

> With word
>     .Documents.Add Template:="\\path\template.dot"
>     .Visible = True
>     .ActiveDocument.SaveAs "\\path\" & name$
> End With

> to make a new document based on the template.  When I do
this, the AutoNew
> UserForm comes up *before* the text of the document. Upon
close, the
> UserForm returns values that are needed to modify

bookmarks in the document,
Quote:
> but the bookmarks aren't there yet, so it errors out.

> Any thoughts?



Tue, 24 Feb 2004 06:50:33 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. UserForm to AutoNew

2. Programmatically create new document and NOT run AutoNew?

3. When userform is shown, another word window comes to focus

4. Switch documents with open userform

5. Userform in global.dot on open of document

6. Attributing values to Document Properties with a UserForm

7. Maintaining Active Document Between Userforms

8. showing a document on a userform

9. Pasting Information From A UserForm To A Word Document

10. How to convert userform and mailmerge input into document properties

11. Open Template UserForm as a Document.

12. UserForms values and multiple document fields

 

 
Powered by phpBB® Forum Software