Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Word doc. 1

Status
Not open for further replies.

lars7

Technical User
Aug 16, 2005
817
GB
Hi Guys,
I'm relly stuck here. I have been asked to look at someone elses database and I cant work out what this command means:

Private Sub Command103_Click()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
gint
'DoCmd.SetWarnings False

End Sub

I cannot find a module or macro that is called "gint" but the command opens 2 word documents, can anyone one tell me why. Thanks as always.
 
It is Refresh, but you are better off with RunCommand.
 
Sorry remou but what is it refreshing when the command button is pushed 2 word documents open.
 
Look for a sub called gint. That is where the documents are being opened.
 
If you ment sub on the same form there is none.
 
No, use Search in the code window and choose Current Project.
 
Hi Remou,
I finally found it but the word doc's I want to find are not in the folder, I am confused.

There is some kind of merge file though:

Function gint()

On Error GoTo MergeButton_Err

Dim myDataBase As Database
Dim myActiveRecord As Recordset
Dim objWord As Object
DoCmd.RunMacro "BuildInt"

Set myDataBase = CurrentDb
Set myActiveRecord = myDataBase.OpenRecordset("MakeInterviewS", dbOpenForwardOnly)
Set objWord = CreateObject("Word.Application")

With objWord
'Make the application visible.
.Visible = True
.Documents.Open ("C:\marge\docs\gint\Intsched.doc")
If myActiveRecord.Fields("InterviewChair") <> "" Then
.ActiveDocument.Bookmarks("Intchair").Select
.Selection.InsertAfter myActiveRecord.Fields("InterviewChair")
End If
If myActiveRecord.Fields("Usename") <> "" Then
.ActiveDocument.Bookmarks("Usename").Select
.Selection.InsertAfter myActiveRecord.Fields("UseName")
End If
If myActiveRecord.Fields("Job Ref No") <> "" Then
.ActiveDocument.Bookmarks("JobRef1").Select
.Selection.InsertAfter myActiveRecord.Fields("Job Ref No")
End If
If myActiveRecord.Fields("VACANCY") <> "" Then
.ActiveDocument.Bookmarks("VACANCY").Select
.Selection.InsertAfter myActiveRecord.Fields("VACANCY")
End If
If myActiveRecord.Fields("Venue") <> "" Then
.ActiveDocument.Bookmarks("Venue").Select
.Selection.InsertAfter myActiveRecord.Fields("Venue")
End If
If myActiveRecord.Fields("Int Date") <> "" Then
.ActiveDocument.Bookmarks("IDate").Select
.Selection.InsertAfter myActiveRecord.Fields("Int Date")
End If
If myActiveRecord.Fields("Location Address") <> "" Then
.ActiveDocument.Bookmarks("Loc_Name").Select
.Selection.InsertAfter myActiveRecord.Fields("Location Address")
End If
If myActiveRecord.Fields("PresDet") <> "" Then
.ActiveDocument.Bookmarks("PresDet").Select
.Selection.InsertAfter myActiveRecord.Fields("PresDet")
End If
If myActiveRecord.Fields("PresLen") <> "" Then
.ActiveDocument.Bookmarks("PresLen").Select
.Selection.InsertAfter myActiveRecord.Fields("PresLen")
End If
If myActiveRecord.Fields("InterviewChair") <> "" Then
.ActiveDocument.Bookmarks("IChair").Select
.Selection.InsertAfter myActiveRecord.Fields("InterviewChair")
End If
' .ActiveDocument.Bookmarks("InterviewManager").Select
' .Selection.InsertAfter myActiveRecord.Fields("InterviewManager")

If myActiveRecord.Fields("InterviewManager1") <> "" Then
.ActiveDocument.Bookmarks("InterviewManager1").Select
.Selection.InsertAfter myActiveRecord.Fields("InterviewManager1")
End If
If myActiveRecord.Fields("InterviewManager2") <> "" Then
.ActiveDocument.Bookmarks("InterviewManager2").Select
.Selection.InsertAfter myActiveRecord.Fields("InterviewManager2")
End If
If myActiveRecord.Fields("InterviewManager3") <> "" Then
.ActiveDocument.Bookmarks("InterviewManager3").Select
.Selection.InsertAfter myActiveRecord.Fields("InterviewManager3")
End If
If myActiveRecord.Fields("IntLen") <> "" Then
.ActiveDocument.Bookmarks("IntLen").Select
.Selection.InsertAfter myActiveRecord.Fields("IntLen")
End If
If myActiveRecord.Fields("Additional Info") <> "" Then
.ActiveDocument.Bookmarks("AddInfo").Select
.Selection.InsertAfter myActiveRecord.Fields("Additional Info")
End If
Do While Not myActiveRecord.EOF


.ActiveDocument.Bookmarks("Enq_ID").Select
.Selection.InsertAfter myActiveRecord.Fields("Fname") & " " & myActiveRecord.Fields("Sname")
.Selection.InsertBefore vbCrLf & vbCrLf
If myActiveRecord.Fields("itime") <> "" Then
.ActiveDocument.Bookmarks("IntTime").Select
.Selection.InsertAfter myActiveRecord.Fields("itime")
End If
.Selection.InsertBefore vbCrLf & vbCrLf
' .ActiveDocument.Bookmarks("Space").Select
myActiveRecord.MoveNext

Loop
' objWord.ActiveDocument.PrintOut Background:=False
'Close the document without saving changes.
' objWord.ActiveDocument.Close SaveChanges:=False
' objWord.Quit
Set objWord = Nothing
Set myDataBase = Nothing

End With

' Set myDataBase = CurrentDb
'Set myActiveRecord = myDataBase.OpenRecordset("MakeInterview", dbOpenForwardOnly)
' Set objWord = CreateObject("Word.Application")
' With objWord
'Make the application visible.
' .Visible = True
' .Documents.Open ("C:\marge\docs\gint\IntAss.doc")
'
' .ActiveDocument.Bookmarks("JobRef").Select
' .Selection.InsertAfter myActiveRecord.Fields("Job Ref No")
' If myActiveRecord.Fields("VACANCY") <> "" Then
' .ActiveDocument.Bookmarks("VACANCY").Select
' .Selection.InsertAfter myActiveRecord.Fields("VACANCY")
' End If
' If myActiveRecord.Fields("Loc_Name") <> "" Then
' .ActiveDocument.Bookmarks("Base").Select
' .Selection.InsertAfter myActiveRecord.Fields("Loc_Name")
' End If

'Do While Not myActiveRecord.EOF

' .ActiveDocument.Bookmarks("Enq_ID").Select
' .Selection.InsertAfter myActiveRecord.Fields("Fname") & " " & myActiveRecord.Fields("Sname")
' .Selection.InsertBefore vbCrLf & vbCrLf

'myActiveRecord.MoveNext

'Loop
' objWord.ActiveDocument.PrintOut Background:=False
'Close the document without saving changes.
' objWord.ActiveDocument.Close SaveChanges:=False
' objWord.Quit
'Set objWord = Nothing
' Set myDataBase = Nothing

'End With

' Set myDataBase = CurrentDb
'Set myActiveRecord = myDataBase.OpenRecordset("MakeInterview", dbOpenForwardOnly)
'Set objWord = CreateObject("Word.Application")
'With objWord
'Make the application visible.
' .Visible = False
' .Documents.Open ("C:\marge\docs\gint\IntSum.doc")

' .ActiveDocument.Bookmarks("JobRef1").Select
' .Selection.InsertAfter myActiveRecord.Fields("Job Ref No")
' If myActiveRecord.Fields("VACANCY") <> "" Then
' .ActiveDocument.Bookmarks("VACANCY1").Select
' .Selection.InsertAfter myActiveRecord.Fields("VACANCY")
' End If
' If myActiveRecord.Fields("Loc_Name") <> "" Then
' .ActiveDocument.Bookmarks("Base1").Select
' .Selection.InsertAfter myActiveRecord.Fields("Loc_Name")
' End If

'Do While Not myActiveRecord.EOF

' .ActiveDocument.Bookmarks("Enq_ID").Select
' .Selection.InsertAfter myActiveRecord.Fields("Fname") & " " & myActiveRecord.Fields("Sname")
' .Selection.InsertBefore vbCrLf & vbCrLf
'
' myActiveRecord.MoveNext
'
'Loop
' objWord.ActiveDocument.PrintOut Background:=False
'Close the document without saving changes.
' objWord.ActiveDocument.Close SaveChanges:=False
' objWord.Quit
'Set objWord = Nothing
' Set myDataBase = Nothing


' End With

Set myDataBase = CurrentDb
Set myActiveRecord = myDataBase.OpenRecordset("MakeInterview", dbOpenForwardOnly)
Set objWord = CreateObject("Word.Application")

With objWord
'Make the application visible.
.Visible = True
.Documents.Open ("C:\marge\docs\gint\Intsign.doc")

.ActiveDocument.Bookmarks("JobRef2").Select
.Selection.InsertAfter myActiveRecord.Fields("Job Ref No")
If myActiveRecord.Fields("VACANCY") <> "" Then
.ActiveDocument.Bookmarks("VACANCY2").Select
.Selection.InsertAfter myActiveRecord.Fields("VACANCY")
End If
End With
' objWord.ActiveDocument.PrintOut Background:=False
'Close the document without saving changes.
' objWord.ActiveDocument.Close SaveChanges:=False
' objWord.Quit
Set objWord = Nothing
Set myDataBase = Nothing

Exit Function
'Then close the database
myActiveRecord.Close
myDataBase.Close

MergeButton_Err:
'If a field on the form is empty, remove the bookmark text, and continue.
If Err.Number <> 94 Then
MsgBox Err.Description & vbCrLf & "Problem ", vbOKOnly + vbCritical, "Error: " & Err.Number

objWord.Selection.Text = "Not Present"
Resume Next
End If

End Function



macro builtint calls a make table query.
there is 3 other word files but none of them look like that are related to this.

sorry that code is so long too.
 
As far as I can see this is opening two Word documents:

C:\marge\docs\gint\Intsched.doc
C:\marge\docs\gint\Intsign.doc

And then filling in data at the bookmarks.

What is the problem?
 
Hi again,
The problem is that there is no files called:

C:\marge\docs\gint\Intsched.doc
C:\marge\docs\gint\Intsign.doc

in the folder, I know that sounds crazy as the doc's open when that button is clicked but I had my boss out looking too and the files are definetly not there.
 
I'm half asleep, there is a macro, so the journey continues:

[tt]DoCmd.RunMacro "BuildInt"[/tt]

You need to look for a macro called BuildInt and find out what it does.
 
Hi again,
I converted the macro and can only see a few queries that supply the information to the files:

Function BuildInt_Macro()
On Error GoTo Copy_Macro_Err

DoCmd.SetWarnings False
DoCmd.OpenQuery "Q_SearchJobReturn30", acViewNormal, acEdit
DoCmd.OpenQuery "UpIntTime", acViewNormal, acEdit
DoCmd.OpenQuery "SMakeInterview", acViewNormal, acEdit
DoCmd.SetWarnings True


BuildInt_Macro:
Exit Function

BuildInt_Macro_Err:
MsgBox Error$
Resume BuildInt_Macro_Exit

End Function
 
Did you ensure that you could see hidden files when you looked in the C:\marge\docs\gint folder?
 
Hi,
Yes I looked for them, I looked in another computer too that the database runs on and the files are in that C drive folder. I'm sure I will be asked to do some more work on this database as the man who designed it has left so I will figure it out another day. Thanks for your time as always.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top