Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2007

Tip: Looking for answers? Try searching our database.

Writing to correct document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stephen English - 09 Jul 2007 04:10 GMT
Hi
I have 30 templates which, when they open (call the instance docA), load a
master template which stores user forms and code applicable to all 30
templates.  I am not and do not wish to put this master template in any Word
startup folder because it is with the 30 master templates in a folder to make
it transportable to offline computers.

After I load the master template, I load the user form which is stored on
the master template.  When I click OK on the user form and update bookmarks,
it trying to find the bookmarks on the Master template whereas I want it to
locate and update them on docA.

Please can anyone tell me how to keep track of this document without saving
it somewhere and reopening it.  docActive in code below is not working.
Thanks
Stephen

Public Sub AutoNew()
Dim strPath As String
Dim obj As Object
Dim docActive As Document

strPath = ActiveDocument.AttachedTemplate.Path & "\"
' Open master template
Set obj = Documents.Open(strPath & "ProjectManagement.dot")
Set docActive = ActiveDocument

Application.Run "FillProjectCombo"
Application.Run "FillNameCombo"
Application.Run "ShowForm1",  docActive

End Sub
Russ - 09 Jul 2007 06:25 GMT
Where's your code for DocA?
like:
Dim DocA As Document
Set DocA = Activedocument
Before you open the template it is based on.

Then you can always refer to DocA and *its* bookmarks.

Did you read all the limitations on the run command in VBA help?
Does your implementation exceed those limits?

>Quote:
Runs a Visual Basic macro.
Note   Only public Sub procedures that take no arguments, which includes all
procedures generated by the macro recorder and all procedures you can run
from the Macros dialog box, can be run by using the Run method.
Syntax
expression.Run(MacroName)
expression   Required. An expression that returns an Application object.
MacroName   Required String. The name of the macro. Can be any combination
of template, module, and macro name. For example, the following statements
are all valid.
Application.Run "Normal.Module1.MAIN"
Application.Run "MyProject.MyModule.MyProcedure"
Application.Run "'My Document.doc'!ThisModule.ThisProcedure"
If you specify the document name, your code can only run macros in documents
related to the current context, not just any macro in any document.
Remarks
Although Visual Basic code can call a macro directly (without this method
being used), this method is useful when the macro name is stored in a
variable (for more information, see the example for this topic). The
following statements are functionally equivalent.
Normal.Module2.Macro1
Call Normal.Module2.Macro1
Application.Run MacroName:="Normal.Module2.Macro1"
You cannot pass parameters to a procedure by using the Run method. Use the
Call statement to pass parameters to a procedure.
>UnQuote:

> Hi
> I have 30 templates which, when they open (call the instance docA), load a
[quoted text clipped - 28 lines]
>
> End Sub

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.