Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

creating a template

Posted on 2006-05-07
4
Medium Priority
?
245 Views
Last Modified: 2010-04-17
Hi guys i have created a word macro which uses a form to connect to an access database.  how would i make this a template which can be movd around on to other machines and how would i reference the database.

thanks
0
Comment
Question by:caz1805
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
Clever_Bob earned 1500 total points
ID: 16628029
1) Sharing the word macro.

Save it as a template (.dot) and share with other users. You can either substitute the file with the existing default template in the file structure or you can load the .dot file you create and you should be given an option to save it as the default template.

2) Accessing Access.

Obviously all of your users will need to be able to connect to the one Access database. This requires that either all your users are on the same LAN or else they all have internet access. Your connection string will be different depending on your environment.

You will need to place your database file on a server of some description (either your own or one provided by your ISP). Essentially you will need to connect to your database using the IP of the machine that is 'hosting' your database.

Hope this helps.
0
 

Author Comment

by:caz1805
ID: 16628041
Thanks a lot i would like to save it in a folder which can then be saved on a cd.  So how would i reference the database within the macro?
0
 
LVL 7

Expert Comment

by:Clever_Bob
ID: 16628316
There will be a line of code that references the database already.

Are using ADO? Do you have a connection string that points to the location of your database file? This is what you need to change.

Rather than pointing to something like c:\Accessdatabase\testdata.mdb you'll need to put the 'testdata.mdb' (as an example) on a server and your macro will point to something like '192.168.1.111\server\Accessdatabase\testdata.mdb'.

As long as you have a burner there will be no problem backing up your database to a CD/DVD.

Probably best if you post your code if you have any more Q's.

Good luck!
0
 

Author Comment

by:caz1805
ID: 16629567
I now can reference the database thank u.  I am using DAO to connect them.  THe problem I am having is that you said to just save it as a template, but I cannot find how to. I will look on the web and see if i can find anything.  Heres my code.

Sub test1()

With ActiveDocument.Bookmarks
   .Add Range:=Selection.Range, Name:="test1"
   .DefaultSorting = wdSortByName
   .ShowHidden = False
End With

Selection.TypeText Text:=vbCrLf
Selection.TypeText Text:=vbCrLf


With ActiveDocument.Bookmarks
   .Add Range:=Selection.Range, Name:="test2"
   .DefaultSorting = wdSortByName
   .ShowHidden = False
End With
   
    UserForm1.Show

End Sub

Dim db As DAO.Database
Dim rs As DAO.Recordset

Private Sub CMD_Click()

    ActiveDocument.Bookmarks("test1").Range.Text = TextBox1.Value
    ActiveDocument.Bookmarks("test2").Range.Text = TextBox2.Value
    TextBox2.Font.Bold = True
    Application.ScreenUpdating = True
    UserForm1.Hide
   
    ActiveDocument.p


End Sub

Private Sub CMD1_Click()

UserForm1.Hide


End Sub

Private Sub CMD2_Click()

    TextBox1.Value = Null
    TextBox2.Value = Null


End Sub

Private Sub CMD3_Click()
    ActiveDocument.Bookmarks("test1").Range.Text = TextBox1.Value
    ActiveDocument.Bookmarks("test2").Range.Text = TextBox2.Value
    TextBox2.Font.Bold = True
    Application.ScreenUpdating = True
    UserForm1.Hide

End Sub

Private Sub Label1_Click()

End Sub

Private Sub Label2_Click()

End Sub

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

    Dim Prts() As String
    Dim tmpTEXT As String

If KeyAscii = 32 Or 48 + 32 + 32 Then
    If TextBox1.Text <> "" Then
        tmpTEXT = TextBox1.Text
        Prts = Split(TextBox1.Text, " ")
        For X = 0 To UBound(Prts)
             rs.FindFirst "[SearchText]='" & Prts(X) & "'"
             If Not rs.NoMatch Then
                  tmpTEXT = Replace(tmpTEXT, Prts(X), rs.Fields("ReplacementText"))
             End If
        Next
       TextBox2.Text = tmpTEXT
    End If
    TextBox2.Text = Replace(tmpTEXT, Chr(9), " ")
End If
End Sub



Private Sub TextBox2_Change()

    TextBox2.Font.Italic = True
   


End Sub


Private Sub UserForm_Initialize()
Set db = OpenDatabase("C:\Documents and Settings\Matthew\Desktop\TEST.mdb")
Set rs = db.OpenRecordset("Translation", dbOpenDynaset)

End Sub
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn different types of Android Layout and some basics of an Android App.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Six Sigma Control Plans

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question