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 / August 2005

Tip: Looking for answers? Try searching our database.

Passing values from one .dot file to another .dot file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Srini - 18 Aug 2005 19:37 GMT
Iam New member for this group!!!!

My project is to pass values from .dot file to another .dot file (lets
say two .dot files test1.dot and test2.dot)

test1.dot: When user runs the macro go(), the wizard / form will be
open to enter the employee number, once he enters, it prints the
Employee number in a document (Doc1) and saved it to the disk, after
this it will open test2.dot

test2.dot: This should calculate the salary based on the employee
number received from the test1.dot, and attach the salary component to
the earlier created file (Doc1) by test1.dot

Iam not sure how to pass the values from one .dot file to another .dot
file
test1.dot code
=============Private Sub CmdFinish1_Click()

   ActiveDocument.Bookmarks("Firs­­tName").Range.Text Me.txtFirstName.Text
   ActiveDocument.Bookmarks("EmpN­­umb").Range.Text = Me.TextBox1
   test1.Enabled = False
   ActiveDocument.SaveAs FileName:="C:\doc1.dot"
   ActiveDocument.SaveAs FileName:="C:\doc2.dot"
   Call test2
   Unload Me
   Application.Quit

End Sub
Public Function test2()
   Dim wrdAppl As Word.Application
   Set wrdAppl = New Word.Application
   wrdAppl.Documents.Open ("C:\test2.dot")
   Set wrdAppl = Nothing
End Function
test2.dot code
=============Private Sub Document_Open()
   ActiveDocument.Bookmarks("bksa­­lary").Range.Text = salary
   test2.Show
End Sub

Public Function salary() As String
   Dim sal As String
   If
(ActiveDocument.CustomDocument­­Properties.Item("Employee").V­a­lue

= "1") Then
     salary = "100K"
   ElseIf
(ActiveDocument.CustomDocument­­Properties.Item("Employee").V­a­lue
= "
") Then
       salary = "Salary not generated"
   End If
End Function

Private Sub CmdFinish2_Click()
       ActiveDocument.Bookmarks("Last­­Name").Range.Text Me.txtLastName.Text
       Dim Doc1 As Word.Document
       Set Doc1 = GetObject("C:\doc1.dot", "Word.Document")
       Doc1.Range = Doc1.Range + ActiveDocument.Range
       Doc1.SaveAs FileName:="C:\doc3.dot"
       Doc1.Close 'close doc3
       Set Doc1 = Nothing
       Unload Me
       ActiveDocument.Close 'close test2.dot
End Sub

in test2.dot
===========I have written code to read the values from customdocumentproperties if
we want to see manually ..open any document go to File menu ->
Properties -> Custom Tab.

What i need is to get the employee number from test1.dot to the custom
properties of the test2.dot so that i can perform necessary salary
calculations

If any of know how to pass the values from .dot file to another .dot
file will be a great help
You can directly mail to me if you need the test1.dot and test2.dot
files for any clarification
I will also update the groups as and when required

Thanks
Srini
Word Heretic - 22 Aug 2005 11:37 GMT
G'day "Srini" <sirumalla.srinivas@gmail.com>,

Template A: Use Tools > References to set a reference to Template B

Now you can call a Public routine from B without a prefix. Eg, If
Template B's macro was MacroB then template A would just

MacroB SomeParm, SomeParm2

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice

Srini reckoned:

>Iam New member for this group!!!!
>
[quoted text clipped - 86 lines]
>Thanks
>Srini
 
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.