Hi I'm working on a database for distance learning. I'm using word to gernerate the report for the exam. The problem is that my application doesn't work without have word open. I'm trying to open a new word document from code but it's run good the first time but when I try to do it again it sends me an error telling me that can not open the server. Actually my aplication is local, so I don't now. What the code do is open a word document and add in the question for the exam which are on anothers word documents.
I send you the code. Please any sugestion would be really apreciated.
Thanks
Trinitri
' This funtion open a new word document application
Public Function sdf()
Dim oApp As Object
Set VarWord = New Word.Application
Set DocWord = VarWord.Documents.Add
VarWord.Visible = True
VarWord.WindowState = wdWindowStateMinimize
End Function
'This function prepare the format for the worddocument, add header and footer and the logo .
Public Function SheetFormat(Title, St, seed, Gen As String) As Boolean
sdf
With DocWord
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type
..........( design of the format)
End With
' This function generate the exam, is the one that I call when the user genetrate the exam, first run the format and after add the question.
Public Function exam(Title, St, seed, Gen As String) As Boolean
Dim SelTab As Recordset
Dim k As Integer
Dim MyName
Dim total As Integer
Dim sdxam As Variant
Dim Prt As Boolean
total = 0
Set MIB = CurrentDb()
Set SelTab = MIB.OpenRecordset("SelectionTable"
Prt = SheetFormat(Title, St, seed, Gen)
Do Until SelTab.EOF
total = total + SelTab![mark]
'( The var MyName is the path of the document who contains the question)
MyName = "C:\Program Files\LManager\WordDoc\" & SelTab![QuCode_qu] & ".doc"
With Selection
.InsertBefore ("(" & SelTab![mark] & " " & SelTab![NoQuestion] & ". "
.MoveDown
.InsertFile FileName:=MyName, ConfirmConversions:=False
.InsertParagraphAfter
.Collapse Direction:=wdCollapseEnd
End With
SelTab.MoveNext
Loop
With Selection
.TypeParagraph
.InsertBefore (" " & total)
.InsertParagraphBefore
.InsertBefore ("________"
.InsertParagraphBefore
Selection.WholeStory
Selection.Font.Name = "Times New Roman"
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 12
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
End With
End function
Well hope that this help , please I need your help, thanks for your time
I send you the code. Please any sugestion would be really apreciated.
Thanks
Trinitri
' This funtion open a new word document application
Public Function sdf()
Dim oApp As Object
Set VarWord = New Word.Application
Set DocWord = VarWord.Documents.Add
VarWord.Visible = True
VarWord.WindowState = wdWindowStateMinimize
End Function
'This function prepare the format for the worddocument, add header and footer and the logo .
Public Function SheetFormat(Title, St, seed, Gen As String) As Boolean
sdf
With DocWord
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type
..........( design of the format)
End With
' This function generate the exam, is the one that I call when the user genetrate the exam, first run the format and after add the question.
Public Function exam(Title, St, seed, Gen As String) As Boolean
Dim SelTab As Recordset
Dim k As Integer
Dim MyName
Dim total As Integer
Dim sdxam As Variant
Dim Prt As Boolean
total = 0
Set MIB = CurrentDb()
Set SelTab = MIB.OpenRecordset("SelectionTable"
Prt = SheetFormat(Title, St, seed, Gen)
Do Until SelTab.EOF
total = total + SelTab![mark]
'( The var MyName is the path of the document who contains the question)
MyName = "C:\Program Files\LManager\WordDoc\" & SelTab![QuCode_qu] & ".doc"
With Selection
.InsertBefore ("(" & SelTab![mark] & " " & SelTab![NoQuestion] & ". "
.MoveDown
.InsertFile FileName:=MyName, ConfirmConversions:=False
.InsertParagraphAfter
.Collapse Direction:=wdCollapseEnd
End With
SelTab.MoveNext
Loop
With Selection
.TypeParagraph
.InsertBefore (" " & total)
.InsertParagraphBefore
.InsertBefore ("________"
.InsertParagraphBefore
Selection.WholeStory
Selection.Font.Name = "Times New Roman"
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 12
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
End With
End function
Well hope that this help , please I need your help, thanks for your time