|
|
I have a 22 page document in Word 2003 in which I have built a userform called frmDataEntry. It is set to load when the document opens and at any other time the user clicks the F3 button. This works most of the time, but sometimes it doesn't. Here are the conditions under which it most often fails and the unacceptable workaround I have had to use the overcome that failure:
1. When I start Word and then open the document, it sometimes works fine and other times not. 2. When it doesn't open the userform, if I invoke the VB Editor and click on the form and then close the VB editor, then save and close the document, it usually works when I reopen it.
This is a big document containing a lot of graphics, custom doc property fields, tables of contents (multiple) and lots of text.
Is there some kind of declaration I should be making in the Module perhaps? The irregularity of the problem is ruining the project.
In "This Document" I have the following code: Sub Document_Open() Load frmDataEntry frmDataEntry.Show End sub Thank you for any insight you can offer.
|
|
Try
Sub Document_Open() Dim myform as frmDataEntry Set myform = New frmDataEntry myform.Show Set myform = Nothing End sub
I question whether this should be a document of a template in which case the above code should be in an AutoNew macro -- Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis.
Doug Robbins - Word MVP
"marjweir" <Weir.Marj[ at ]charter.net> wrote in message news:94ebc953-c254-4ae3-9df9-c05ab84e8f20[ at ]35g2000pry.googlegroups.com...
[Quoted Text] >I have a 22 page document in Word 2003 in which I have built a > userform called frmDataEntry. It is set to load when the document > opens and at any other time the user clicks the F3 button. This works > most of the time, but sometimes it doesn't. Here are the conditions > under which it most often fails and the unacceptable workaround I have > had to use the overcome that failure: > > 1. When I start Word and then open the document, it sometimes works > fine and other times not. > 2. When it doesn't open the userform, if I invoke the VB Editor and > click on the form and then close the VB editor, then save and close > the document, it usually works when I reopen it. > > This is a big document containing a lot of graphics, custom doc > property fields, tables of contents (multiple) and lots of text. > > Is there some kind of declaration I should be making in the Module > perhaps? The irregularity of the problem is ruining the project. > > In "This Document" I have the following code: > Sub Document_Open() > Load frmDataEntry > frmDataEntry.Show > End sub > Thank you for any insight you can offer.
|
|
On Nov 14, 5:31 am, "Doug Robbins - Word MVP" <d...[ at ]REMOVECAPSmvps.org> wrote:
[Quoted Text] > Try > > Sub Document_Open() > Dim myform as frmDataEntry > Set myform = New frmDataEntry > myform.Show > Set myform = Nothing > End sub > > I question whether this should be a document of a template in which case the > above code should be in an AutoNew macro > -- > Hope this helps. > > Please reply to the newsgroup unless you wish to avail yourself of my > services on a paid consulting basis. > > Doug Robbins - Word MVP > > "marjweir" <Weir.M...[ at ]charter.net> wrote in message > > news:94ebc953-c254-4ae3-9df9-c05ab84e8f20[ at ]35g2000pry.googlegroups.com... > > > > >I have a 22 page document in Word 2003 in which I have built a > > userform called frmDataEntry. It is set to load when the document > > opens and at any other time the user clicks the F3 button. This works > > most of the time, but sometimes it doesn't. Here are the conditions > > under which it most often fails and the unacceptable workaround I have > > had to use the overcome that failure: > > > 1. When I start Word and then open the document, it sometimes works > > fine and other times not. > > 2. When it doesn't open the userform, if I invoke the VB Editor and > > click on the form and then close the VB editor, then save and close > > the document, it usually works when I reopen it. > > > This is a big document containing a lot of graphics, custom doc > > property fields, tables of contents (multiple) and lots of text. > > > Is there some kind of declaration I should be making in the Module > > perhaps? The irregularity of the problem is ruining the project. > > > In "This Document" I have the following code: > > Sub Document_Open() > > Load frmDataEntry > > frmDataEntry.Show > > End sub > > Thank you for any insight you can offer.- Hide quoted text - > > - Show quoted text -
Thanks, Doug. This will eventually be a template, but I'm still building it in .doc form. I want my form to be available via F3 so when action is completed on the form, I am just hiding it. Later I show it again. Doesn't Set Myform = nothing have the effect of closing the object so that it won't be accessible via F3?
|
|
It would depend upon what code you are invoking by the use of F3.
There is no reason not to start with a template.
-- Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis.
Doug Robbins - Word MVP
"marjweir" <Weir.Marj[ at ]charter.net> wrote in message news:e8f21d41-c69f-4406-94c3-bd2ab96516ce[ at ]s9g2000prg.googlegroups.com... On Nov 14, 5:31 am, "Doug Robbins - Word MVP" <d...[ at ]REMOVECAPSmvps.org> wrote:
[Quoted Text] > Try > > Sub Document_Open() > Dim myform as frmDataEntry > Set myform = New frmDataEntry > myform.Show > Set myform = Nothing > End sub > > I question whether this should be a document of a template in which case > the > above code should be in an AutoNew macro > -- > Hope this helps. > > Please reply to the newsgroup unless you wish to avail yourself of my > services on a paid consulting basis. > > Doug Robbins - Word MVP > > "marjweir" <Weir.M...[ at ]charter.net> wrote in message > > news:94ebc953-c254-4ae3-9df9-c05ab84e8f20[ at ]35g2000pry.googlegroups.com... > > > > >I have a 22 page document in Word 2003 in which I have built a > > userform called frmDataEntry. It is set to load when the document > > opens and at any other time the user clicks the F3 button. This works > > most of the time, but sometimes it doesn't. Here are the conditions > > under which it most often fails and the unacceptable workaround I have > > had to use the overcome that failure: > > > 1. When I start Word and then open the document, it sometimes works > > fine and other times not. > > 2. When it doesn't open the userform, if I invoke the VB Editor and > > click on the form and then close the VB editor, then save and close > > the document, it usually works when I reopen it. > > > This is a big document containing a lot of graphics, custom doc > > property fields, tables of contents (multiple) and lots of text. > > > Is there some kind of declaration I should be making in the Module > > perhaps? The irregularity of the problem is ruining the project. > > > In "This Document" I have the following code: > > Sub Document_Open() > > Load frmDataEntry > > frmDataEntry.Show > > End sub > > Thank you for any insight you can offer.- Hide quoted text - > > - Show quoted text -
Thanks, Doug. This will eventually be a template, but I'm still building it in .doc form. I want my form to be available via F3 so when action is completed on the form, I am just hiding it. Later I show it again. Doesn't Set Myform = nothing have the effect of closing the object so that it won't be accessible via F3?
|
|
On Nov 14, 1:38 pm, marjweir <Weir.M...[ at ]charter.net> wrote:
[Quoted Text] > On Nov 14, 5:31 am, "Doug Robbins - Word MVP" > > > > > > <d...[ at ]REMOVECAPSmvps.org> wrote: > > Try > > > Sub Document_Open() > > Dim myform as frmDataEntry > > Set myform = New frmDataEntry > > myform.Show > > Set myform = Nothing > > End sub > > > I question whether this should be a document of a template in which case the > > above code should be in an AutoNew macro > > -- > > Hope this helps. > > > Please reply to the newsgroup unless you wish to avail yourself of my > > services on a paid consulting basis. > > > Doug Robbins - Word MVP > > > "marjweir" <Weir.M...[ at ]charter.net> wrote in message > > >news:94ebc953-c254-4ae3-9df9-c05ab84e8f20[ at ]35g2000pry.googlegroups.com... > > > >I have a 22 page document in Word 2003 in which I have built a > > > userform called frmDataEntry. It is set to load when the document > > > opens and at any other time the user clicks the F3 button. This works > > > most of the time, but sometimes it doesn't. Here are the conditions > > > under which it most often fails and the unacceptable workaround I have > > > had to use the overcome that failure: > > > > 1. When I start Word and then open the document, it sometimes works > > > fine and other times not. > > > 2. When it doesn't open the userform, if I invoke the VB Editor and > > > click on the form and then close the VB editor, then save and close > > > the document, it usually works when I reopen it. > > > > This is a big document containing a lot of graphics, custom doc > > > property fields, tables of contents (multiple) and lots of text. > > > > Is there some kind of declaration I should be making in the Module > > > perhaps? The irregularity of the problem is ruining the project. > > > > In "This Document" I have the following code: > > > Sub Document_Open() > > > Load frmDataEntry > > > frmDataEntry.Show > > > End sub > > > Thank you for any insight you can offer.- Hide quoted text - > > > - Show quoted text - > > Thanks, Doug. > This will eventually be a template, but I'm still building it in .doc > form. > I want my form to be available via F3 so when action is completed on > the form, I am just hiding it. Later I show it again. Doesn't Set > Myform = nothing have the effect of closing the object so that it > won't be accessible via F3?- Hide quoted text - > > - Show quoted text -
I tried using your code, but there must be something else wrong. It fails and reports the error 53 - file not found. When I debug, the line it fails on is set myform = New frmDataEntry When I mouseover frmDataEntry, I get <object variable or With block variable not set>
Here's the Project Explorer content with a new document open (sans the graphics). +Normal -Project(Formdoc) 'this is the template -Microsoft Word Objects ThisDocument 'contains subs for Document_New, Document_Open and Document_Close -Forms frmDataEntry -Modules Module1 'just contains code for F3 -Project(Mynewdoc) 'new doc created from template -Microsoft Word Objects ThisDocument -References References to Formdoc.dot
Can you see any reason why it shouldn't be able to find frmDataEntry or is that just the closest error the system could find?
Thanks.
|
|
If you want to send me a copy of the template, I will take a look at it.
-- Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis.
Doug Robbins - Word MVP
"marjweir" <Weir.Marj[ at ]charter.net> wrote in message news:7d457c4c-09c9-45aa-9d1b-105606e363f6[ at ]i18g2000prf.googlegroups.com... On Nov 14, 1:38 pm, marjweir <Weir.M...[ at ]charter.net> wrote:
[Quoted Text] > On Nov 14, 5:31 am, "Doug Robbins - Word MVP" > > > > > > <d...[ at ]REMOVECAPSmvps.org> wrote: > > Try > > > Sub Document_Open() > > Dim myform as frmDataEntry > > Set myform = New frmDataEntry > > myform.Show > > Set myform = Nothing > > End sub > > > I question whether this should be a document of a template in which case > > the > > above code should be in an AutoNew macro > > -- > > Hope this helps. > > > Please reply to the newsgroup unless you wish to avail yourself of my > > services on a paid consulting basis. > > > Doug Robbins - Word MVP > > > "marjweir" <Weir.M...[ at ]charter.net> wrote in message > > >news:94ebc953-c254-4ae3-9df9-c05ab84e8f20[ at ]35g2000pry.googlegroups.com... > > > >I have a 22 page document in Word 2003 in which I have built a > > > userform called frmDataEntry. It is set to load when the document > > > opens and at any other time the user clicks the F3 button. This works > > > most of the time, but sometimes it doesn't. Here are the conditions > > > under which it most often fails and the unacceptable workaround I have > > > had to use the overcome that failure: > > > > 1. When I start Word and then open the document, it sometimes works > > > fine and other times not. > > > 2. When it doesn't open the userform, if I invoke the VB Editor and > > > click on the form and then close the VB editor, then save and close > > > the document, it usually works when I reopen it. > > > > This is a big document containing a lot of graphics, custom doc > > > property fields, tables of contents (multiple) and lots of text. > > > > Is there some kind of declaration I should be making in the Module > > > perhaps? The irregularity of the problem is ruining the project. > > > > In "This Document" I have the following code: > > > Sub Document_Open() > > > Load frmDataEntry > > > frmDataEntry.Show > > > End sub > > > Thank you for any insight you can offer.- Hide quoted text - > > > - Show quoted text - > > Thanks, Doug. > This will eventually be a template, but I'm still building it in .doc > form. > I want my form to be available via F3 so when action is completed on > the form, I am just hiding it. Later I show it again. Doesn't Set > Myform = nothing have the effect of closing the object so that it > won't be accessible via F3?- Hide quoted text - > > - Show quoted text -
I tried using your code, but there must be something else wrong. It fails and reports the error 53 - file not found. When I debug, the line it fails on is set myform = New frmDataEntry When I mouseover frmDataEntry, I get <object variable or With block variable not set>
Here's the Project Explorer content with a new document open (sans the graphics). +Normal -Project(Formdoc) 'this is the template -Microsoft Word Objects ThisDocument 'contains subs for Document_New, Document_Open and Document_Close -Forms frmDataEntry -Modules Module1 'just contains code for F3 -Project(Mynewdoc) 'new doc created from template -Microsoft Word Objects ThisDocument -References References to Formdoc.dot
Can you see any reason why it shouldn't be able to find frmDataEntry or is that just the closest error the system could find?
Thanks.
|
|
On Nov 14, 8:43 pm, "Doug Robbins - Word MVP" <d...[ at ]REMOVECAPSmvps.org> wrote:
[Quoted Text] > If you want to send me a copy of the template, I will take a look at it. > > -- > Hope this helps. > > Please reply to the newsgroup unless you wish to avail yourself of my > services on a paid consulting basis. > > Doug Robbins - Word MVP > > "marjweir" <Weir.M...[ at ]charter.net> wrote in message > > news:7d457c4c-09c9-45aa-9d1b-105606e363f6[ at ]i18g2000prf.googlegroups.com... > On Nov 14, 1:38 pm, marjweir <Weir.M...[ at ]charter.net> wrote: > > > > > > > On Nov 14, 5:31 am, "Doug Robbins - Word MVP" > > > <d...[ at ]REMOVECAPSmvps.org> wrote: > > > Try > > > > Sub Document_Open() > > > Dim myform as frmDataEntry > > > Set myform = New frmDataEntry > > > myform.Show > > > Set myform = Nothing > > > End sub > > > > I question whether this should be a document of a template in which case > > > the > > > above code should be in an AutoNew macro > > > -- > > > Hope this helps. > > > > Please reply to the newsgroup unless you wish to avail yourself of my > > > services on a paid consulting basis. > > > > Doug Robbins - Word MVP > > > > "marjweir" <Weir.M...[ at ]charter.net> wrote in message > > > >news:94ebc953-c254-4ae3-9df9-c05ab84e8f20[ at ]35g2000pry.googlegroups.com.... > > > > >I have a 22 page document in Word 2003 in which I have built a > > > > userform called frmDataEntry. It is set to load when the document > > > > opens and at any other time the user clicks the F3 button. This works > > > > most of the time, but sometimes it doesn't. Here are the conditions > > > > under which it most often fails and the unacceptable workaround I have > > > > had to use the overcome that failure: > > > > > 1. When I start Word and then open the document, it sometimes works > > > > fine and other times not. > > > > 2. When it doesn't open the userform, if I invoke the VB Editor and > > > > click on the form and then close the VB editor, then save and close > > > > the document, it usually works when I reopen it. > > > > > This is a big document containing a lot of graphics, custom doc > > > > property fields, tables of contents (multiple) and lots of text. > > > > > Is there some kind of declaration I should be making in the Module > > > > perhaps? The irregularity of the problem is ruining the project. > > > > > In "This Document" I have the following code: > > > > Sub Document_Open() > > > > Load frmDataEntry > > > > frmDataEntry.Show > > > > End sub > > > > Thank you for any insight you can offer.- Hide quoted text - > > > > - Show quoted text - > > > Thanks, Doug. > > This will eventually be a template, but I'm still building it in .doc > > form. > > I want my form to be available via F3 so when action is completed on > > the form, I am just hiding it. Later I show it again. Doesn't Set > > Myform = nothing have the effect of closing the object so that it > > won't be accessible via F3?- Hide quoted text - > > > - Show quoted text - > > I tried using your code, but there must be something else wrong. It > fails and reports the error 53 - file not found. When I debug, the > line it fails on is set myform = New frmDataEntry > When I mouseover frmDataEntry, I get <object variable or With block > variable not set> > > Here's the Project Explorer content with a new document open (sans the > graphics). > +Normal > -Project(Formdoc) 'this is the template > -Microsoft Word Objects > ThisDocument 'contains subs for Document_New, Document_Open > and Document_Close > -Forms > frmDataEntry > -Modules > Module1 'just contains code for F3 > -Project(Mynewdoc) 'new doc created from template > -Microsoft Word Objects > ThisDocument > -References > References to Formdoc.dot > > Can you see any reason why it shouldn't be able to find frmDataEntry > or is that just the closest error the system could find? > > Thanks.- Hide quoted text - > > - Show quoted text -
Well, I think I figured it out. The problem was with code within the form. I guess it wouldn't load it because it couldn't find a text file that was in the same directory, but did not have a path explicitly identified. It works consistently on my development pc now that I have created an explicit file path for the text file the form grabs data from.
Once again, "Assume nothing" seems to be wise.
Thanks. Marj
|
|
|