R
Robin
I have an OLE unbound frame linked to a Word 2007 document on a form and on a
subform embedded in a report. And the following code will change the Source
Doc property files. But it has to be run twice to accomplish the changes. I
am at a loss for why. A command button on click property executes the code
which opens a file selector dialog box to specify the path and filename, and
then updates the Source Doc properties.
But when I click the command button it goes through all of the proper steps.
Asks for the file and when selected, I can see the instances of word open on
the task bar. But the files are not changed. If I click the button and
select the same file a second time, everything appears to work the same, word
instances, etc., but the files actually change.
Private Sub cmdChangeAD_Click()
On Error GoTo Err_cmdChangeAD_Click
' Allows User to select file for new AD copy on the Billing Invoices.
Me!BillingMemo = BrowseForFile("Please Select Desired Word Document")
' Opens the form and updates the Source Doc property of the ole field.
DoCmd.OpenForm "InvoicesToPrintForm", acNormal, , , acFormPropertySettings,
acHidden
Forms!InvoicesToPrintForm.Controls!OLEUnbound49.Class = "word.docx"
Forms!InvoicesToPrintForm.Controls!OLEUnbound49.OLETypeAllowed = acOLELinked
Forms!InvoicesToPrintForm.Controls!OLEUnbound49.SourceDoc = Me!BillingMemo
Forms!InvoicesToPrintForm.Controls!OLEUnbound49.Action = acOLECreateLink
DoCmd.Close acForm, "InvoicesToPrintForm", acSaveYes
' Opens the subform on report and updates the Source Doc property of the ole
field.
DoCmd.OpenForm "frmBillingFormSub", acNormal, , , acFormPropertySettings,
acHidden
Forms!frmBillingFormSub.Controls!OLEUnbound0.Class = "word.docx"
Forms!frmBillingFormSub.Controls!OLEUnbound0.OLETypeAllowed = acOLELinked
Forms!frmBillingFormSub.Controls!OLEUnbound0.SourceDoc = Me!BillingMemo
Forms!frmBillingFormSub.Controls!OLEUnbound0.Action = acOLECreateLink
DoCmd.Close acForm, "frmBillingFormSub", acSaveYes
Exit_cmdChangeAD_Click:
Exit Sub
Err_cmdChangeAD_Click:
MsgBox Err.Description
Resume Exit_cmdChangeAD_Click
End Sub
Any suggestions would be greatly appreciated. If I can nail this down I can
deliver the project.
Thank you,
Robin
subform embedded in a report. And the following code will change the Source
Doc property files. But it has to be run twice to accomplish the changes. I
am at a loss for why. A command button on click property executes the code
which opens a file selector dialog box to specify the path and filename, and
then updates the Source Doc properties.
But when I click the command button it goes through all of the proper steps.
Asks for the file and when selected, I can see the instances of word open on
the task bar. But the files are not changed. If I click the button and
select the same file a second time, everything appears to work the same, word
instances, etc., but the files actually change.
Private Sub cmdChangeAD_Click()
On Error GoTo Err_cmdChangeAD_Click
' Allows User to select file for new AD copy on the Billing Invoices.
Me!BillingMemo = BrowseForFile("Please Select Desired Word Document")
' Opens the form and updates the Source Doc property of the ole field.
DoCmd.OpenForm "InvoicesToPrintForm", acNormal, , , acFormPropertySettings,
acHidden
Forms!InvoicesToPrintForm.Controls!OLEUnbound49.Class = "word.docx"
Forms!InvoicesToPrintForm.Controls!OLEUnbound49.OLETypeAllowed = acOLELinked
Forms!InvoicesToPrintForm.Controls!OLEUnbound49.SourceDoc = Me!BillingMemo
Forms!InvoicesToPrintForm.Controls!OLEUnbound49.Action = acOLECreateLink
DoCmd.Close acForm, "InvoicesToPrintForm", acSaveYes
' Opens the subform on report and updates the Source Doc property of the ole
field.
DoCmd.OpenForm "frmBillingFormSub", acNormal, , , acFormPropertySettings,
acHidden
Forms!frmBillingFormSub.Controls!OLEUnbound0.Class = "word.docx"
Forms!frmBillingFormSub.Controls!OLEUnbound0.OLETypeAllowed = acOLELinked
Forms!frmBillingFormSub.Controls!OLEUnbound0.SourceDoc = Me!BillingMemo
Forms!frmBillingFormSub.Controls!OLEUnbound0.Action = acOLECreateLink
DoCmd.Close acForm, "frmBillingFormSub", acSaveYes
Exit_cmdChangeAD_Click:
Exit Sub
Err_cmdChangeAD_Click:
MsgBox Err.Description
Resume Exit_cmdChangeAD_Click
End Sub
Any suggestions would be greatly appreciated. If I can nail this down I can
deliver the project.
Thank you,
Robin