|
-
Make VB code work in MS Access 2000?
Dear Mr/Mrs/Ms, Linkoping, Sweden 160702
I have written VB code in MS VB 6.0 and from there it can be run. Now I want
to connect the code with MS Access 2000 and I have just found out that there
I have to write the code in VBA. Now to my question. How, where and what
in the VB code shall I change to get the VBA code to be executed. Below you
can see some of the code:
'start of code
Option Explicit
'subroutine for the button for choose of groundprofile (GrundProfil)
Private Sub Grund_Click()
Call Uppdatera(1) 'Grund.dot
End Sub
'subroutine for the button for choose of forthedayprofile (ForDagenProfil)
Private Sub ForDagen_Click()
Call Uppdatera(2) 'ForDagen.dot
End Sub
'subroutine for uppdateing of profile
Private Sub Uppdatera(ByVal dotVal As Long)
'declaration of Word
Dim wd As Word.Application
'declaration of document in Word
Dim doc As Word.Document
'declaration of field in Word there the text will be shown
Dim ran As Range
'declaration of bookmark in Word there the specific text shall stand
Dim book As Bookmark
On Error Resume Next
Set wd = GetObject(, "Word.Application")
If wd Is Nothing Then
Set wd = CreateObject("Word.Application")
If wd Is Nothing Then
MsgBox ("MS Word is not installed")
End If
End If
On Error GoTo 0
Select Case dotVal
Case Is = 1
'path to folder there the groundprofile is
Set doc = Documents.Add("\\combitechsystems.com\CS\Transfer\Linköping\"
& _
"Johanna Pihlström\Konsultprofil\Version1\Wordmallar\Grund.dot")
'paste all the statments the shall be in this profile
'name calls and writes in
Set book = doc.Bookmarks.Item("namn")
Set ran = book.Range
ran.Text = namn.Text
Grund.Caption = namn.Text
'have deleted the rest because to fit more space in the post
Case Is = 2
'path to folder there the forthedayprofile is
Set doc = Documents.Add("\\combitechsystems.com\CS\Transfer\Linköping\"
& _
"Johanna Pihlström\Konsultprofil\Version1\Wordmallar\ForDagen.dot")
'paste all the statments the shall be in this profile
'name calls and writes in
Set book = doc.Bookmarks.Item("namn")
Set ran = book.Range
ran.Text = namn.Text
ForDagen.Caption = namn.Text
'have deleted the rest because to fit more space in the post
End Select
wd.Visible = True
doc.Saved = True
End Sub
'end of code
Hope you understand my woundering.
Thanks in advance!
Johanna Pihlström
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks