I'm trying to create a button on a chart that will exports the chart and appends it to a Word doc named "Export Graphs".
My problem is that right now the code opens "Export Graphs" and then copies and pastes the chart into a new Word doc. Also, I'm not sure how to have the copied chart append itself to "Export Graphs".
Any help or suggestions would be great. Thanks, Kopy.
Here's my current code:
Private Sub cmdExport_Click()
Dim wd As Word.Application
Dim wordDoc As Word.Document
Dim frm As Form
Dim ctl As Control
'Copy the Current Graph
Set frm = Forms![grphExposuresByJobCategory(SharpsOnly)]
Set ctl = Forms![grphExposuresByJobCategory(SharpsOnly)].Graph1
frm(ctl.Name).Enabled = True
frm(ctl.Name).SetFocus
DoCmd.RunCommand acCmdCopy
'Open the "Exported Graphs" Word File
Set wd = New Word.Application
With wd
.Visible = True
Set wordDoc = .Documents.Open("C:\Impact Consulting\Partners\Occ Health\NWH\In Development\Exported Graphs.doc", , False)
End With
'Paste the Current Graph to "Exported Graphs"
With wd
.Visible = True
.Documents.Add
.Selection.PasteSpecial False, wdPasteOLEObject, wdFloatOverText, False
End With
'Reset Propeties
Set wd = Nothing
Me.cmdExport.SetFocus
frm(ctl.Name).Enabled = False
End Sub
My problem is that right now the code opens "Export Graphs" and then copies and pastes the chart into a new Word doc. Also, I'm not sure how to have the copied chart append itself to "Export Graphs".
Any help or suggestions would be great. Thanks, Kopy.
Here's my current code:
Private Sub cmdExport_Click()
Dim wd As Word.Application
Dim wordDoc As Word.Document
Dim frm As Form
Dim ctl As Control
'Copy the Current Graph
Set frm = Forms![grphExposuresByJobCategory(SharpsOnly)]
Set ctl = Forms![grphExposuresByJobCategory(SharpsOnly)].Graph1
frm(ctl.Name).Enabled = True
frm(ctl.Name).SetFocus
DoCmd.RunCommand acCmdCopy
'Open the "Exported Graphs" Word File
Set wd = New Word.Application
With wd
.Visible = True
Set wordDoc = .Documents.Open("C:\Impact Consulting\Partners\Occ Health\NWH\In Development\Exported Graphs.doc", , False)
End With
'Paste the Current Graph to "Exported Graphs"
With wd
.Visible = True
.Documents.Add
.Selection.PasteSpecial False, wdPasteOLEObject, wdFloatOverText, False
End With
'Reset Propeties
Set wd = Nothing
Me.cmdExport.SetFocus
frm(ctl.Name).Enabled = False
End Sub