ChrisCione
Board Regular
- Joined
- Aug 27, 2008
- Messages
- 92
- Office Version
- 365
- Platform
- Windows
How do I combine this code (which opens a specific Word fillable form based on a combo box selection):
Select Case Me.ComboWord
Case Is = "ERS"
Application.FollowHyperlink "L:\Bper Spec\Cione\Database Files\Announcement (ERS NonRep BroadBand).doc"
Case Is = "Open"
Application.FollowHyperlink "L:\Bper Spec\Cione\Database Files\Announcement (OPEN NonRep BroadBand).doc"
Case Else
' do nothing
End Select
with this code (which exports data into corresponding form fields in a Word template)?
Private Sub CommandERSNRBB_Click()
'Download to ERS NonRep Broadband.
Dim appWord As Word.Application
Dim doc As Word.Document
'Avoid error 429, when Word isn’t open.
On Error Resume Next
Err.Clear
'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'If Word isn’t open, create a new instance of Word.
Set appWord = New Word.Application
End If
Set doc = appWord.Documents.Open("L:\Bper Spec\Cione\Database Files\Announcement (ERS NonRep BroadBand).doc", , True)
With doc
.FormFields("Specialist").Result = Me!Specialist
.FormFields("Classification").Result = Me!Classification
.FormFields("ClassCode").Result = Me!ClassCode
.FormFields("JobAnnoID").Result = Me!JobAnnoID
.FormFields("JobAnnoCode").Result = Me!JobAnnoCode
.FormFields("Cert").Result = Me!CertNumber
.FormFields("PositionNumber").Result = Me!PositionNumber .Visible = True
.Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
End Sub <!--IBF.ATTACHMENT_2062125-->
Select Case Me.ComboWord
Case Is = "ERS"
Application.FollowHyperlink "L:\Bper Spec\Cione\Database Files\Announcement (ERS NonRep BroadBand).doc"
Case Is = "Open"
Application.FollowHyperlink "L:\Bper Spec\Cione\Database Files\Announcement (OPEN NonRep BroadBand).doc"
Case Else
' do nothing
End Select
with this code (which exports data into corresponding form fields in a Word template)?
Private Sub CommandERSNRBB_Click()
'Download to ERS NonRep Broadband.
Dim appWord As Word.Application
Dim doc As Word.Document
'Avoid error 429, when Word isn’t open.
On Error Resume Next
Err.Clear
'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'If Word isn’t open, create a new instance of Word.
Set appWord = New Word.Application
End If
Set doc = appWord.Documents.Open("L:\Bper Spec\Cione\Database Files\Announcement (ERS NonRep BroadBand).doc", , True)
With doc
.FormFields("Specialist").Result = Me!Specialist
.FormFields("Classification").Result = Me!Classification
.FormFields("ClassCode").Result = Me!ClassCode
.FormFields("JobAnnoID").Result = Me!JobAnnoID
.FormFields("JobAnnoCode").Result = Me!JobAnnoCode
.FormFields("Cert").Result = Me!CertNumber
.FormFields("PositionNumber").Result = Me!PositionNumber .Visible = True
.Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
End Sub <!--IBF.ATTACHMENT_2062125-->