De fleste virksomheder har efterhånden bevist, at AI virker.
Pilotprojekter leverer resultater. Medarbejdere bruger generative AI-værktøjer. Nye use cases dukker op på tværs af organisationen.
'Place this in a module Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Const SW_HIDE = 0 Public Const SW_SHOW = 5
'This is behind a button on the form. When you select a record you can press th ebutton to open the document
Private Sub Command1_Click() Dim stAppPath As String Dim stAppName As String Dim result As Integer
On Error GoTo Err_Command1_Click
stAppName = Me.SomeFieldOnTheForm
result = ShellExecute(0, "Open", stAppName, "", "", SW_SHOW)
If result < 32 Then MsgBox "Couldn't open file ..." End If
Idfet jeg ikke mener der er nogen grund til at åbne et Word-dokument uden samtidig at overføre data fra Access, kan flg kode benyttes. Den åbner et berstemt Word-dokument, og overfører samtidig formularens data til word:
Dim objword As New Word.Application Dim WordDoc As New Word.Document Set WordDoc = objword.Documents.Add("D:\VBA funktioner\VBA\Opskrifter\Opskrift.doc") Call InsertAtBookmark(WordDoc, "Opskrift", Me!Opskrift) objword.Visible = True DoCmd.Hourglass False
'Ny funktion Function InsertAtBookmark(objWordDoc As Word.Document, strBookmark As String, strText As String) As Boolean With objWordDoc.Bookmarks If .Exists(strBookmark) Then .Item(strBookmark).Range.Text = strText InsertAtBookmark = True End If End With End Function
The line Public Declare Function ShellExecute .... is telling Access that it can find a Function named ShellExecute in a file which is VERY likely installed on your PC (shell32.dll)
This line actually calls the fnction and the stAppName should now contain "Jeg har et tekstfelt i min db, hvor stien til et ekstern dokument ligger." In other words the name of the dcoument you want to open.
result = ShellExecute(0, "Open", stAppName, "", "", SW_SHOW)
mugs>Example: I recently made a program which registered ALL buildings owned by LEGO. They also wanted to archive ALL documents concerning each building, and it should be possible to open thes edocuments and edit them. Nothing to do with copying data from Access to the document. It could be CAD CAM drawing of the building for example.
terry > In your example the best must bee to store the information in an Access-db. Search after the building in your db, and when you have founded it, then click on a command-button and access will find the correct document in word. LEGO must own a lot off buildings, so the task for store data off them is a task for Access.
the word-documents are stored with a building no, that matches the same field in access, and when you have found the building no in access, then you click on a command button, and acess will open the word-document with the same building no.
I have a table which has a reference to th ebuilding and a path+filename to the document. There can be many documents so they get displayed in a list with a comment they can choose the document form the list and it gets opended for viewing. They have around 300 I think (In DK alone)
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.