creating a template

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
caz1805Asked:
Who is Participating?
 
Clever_BobCommented:
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
 
caz1805Author Commented:
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
 
Clever_BobCommented:
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
 
caz1805Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.