By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,397 Members | 1,425 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,397 IT Pros & Developers. It's quick & easy.

OLE Automation

P: 3
Trying to automate the embed of word docs. Using the following code which worked for me in Acess 2k but is not working in 2003. Any suggestions?

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_Insert_DOC_Click()
  2. On Error GoTo errhand2
  3.  
  4.  
  5. Dim arbc As String
  6. Dim iss As String
  7.  
  8. arbc = Me![Arb_Counter].Value
  9. iss = "c:\FILES\Issue" & arbc & ".DOC"
  10.  
  11. Debug.Print fname
  12.  
  13. Decision.SourceDoc = fname
  14. Decision.Action = OLe_Create_embed
  15.  
  16. errhand2:
  17. Debug.Print Err
  18. Resume Next
  19. End Sub
  20.  
Aug 8 '07 #1
Share this Question
Share on Google+
5 Replies


JKing
Expert 100+
P: 1,206
You have posted your question in the Access Articles section rather than the Access Forum section.
I have moved it across for you.

MODERATOR.
Aug 8 '07 #2

Scott Price
Expert 100+
P: 1,384
Assuming that "Decision" is your named unbound object frame, you need to change the
Expand|Select|Wrap|Line Numbers
  1. Decision.Action = OLE_create_embed
to
Expand|Select|Wrap|Line Numbers
  1. Decision.Action = acOLECreateEmbed
The code you posted isn't quite complete, in that it doesn't give us any idea of where you are getting your 'fname' variable from... It LOOKS like you should be setting the sourcedoc to iss, rather than fname (unless, that is, you are declaring fname elsewhere in the module and simply passing the value here.)

Regards,
Scott
Aug 8 '07 #3

ADezii
Expert 5K+
P: 8,669
Trying to automate the embed of word docs. Using the following code which worked for me in Acess 2k but is not working in 2003. Any suggestions?

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_Insert_DOC_Click()
  2. On Error GoTo errhand2
  3.  
  4.  
  5. Dim arbc As String
  6. Dim iss As String
  7.  
  8. arbc = Me![Arb_Counter].Value
  9. iss = "c:\FILES\Issue" & arbc & ".DOC"
  10.  
  11. Debug.Print fname
  12.  
  13. Decision.SourceDoc = fname
  14. Decision.Action = OLe_Create_embed
  15.  
  16. errhand2:
  17. Debug.Print Err
  18. Resume Next
  19. End Sub
  20.  
Unless you omitted some critical code, your posted code should not work at all. To programmatically Embed an Object in an Unbound Object Frame:
Expand|Select|Wrap|Line Numbers
  1. 'Define the type of Object to appear in the Field
  2. Me![OLEUnbound1].OLETypeAllowed = acOLEEmbedded
  3.  
  4. 'Specify File to be Embedded
  5. Me![OLEUnbound1].SourceDoc = "C:\Test\Test.xls"
  6.  
  7. 'Critical steps for Embedding and In-Place Activation
  8. Me![OLEUnbound1].Enabled = True
  9. Me![OLEUnbound1].Locked = False
  10.  
  11. 'Craete the Embedded Object
  12. Me![OLEUnbound1].Action = acOLECreateEmbed
Aug 8 '07 #4

Scott Price
Expert 100+
P: 1,384
Thanks, Adezii!

Suggestion to OP... Read Access's help file under "sourcedoc" (position cursor in the word somewhere in your code window and press F1). Not always nearly as clear as mud, but in this case I think it explains the process fairly well.

Regards,
Scott
Aug 8 '07 #5

P: 3
Assuming that "Decision" is your named unbound object frame, you need to change the
Expand|Select|Wrap|Line Numbers
  1. Decision.Action = OLE_create_embed
to
Expand|Select|Wrap|Line Numbers
  1. Decision.Action = acOLECreateEmbed
The code you posted isn't quite complete, in that it doesn't give us any idea of where you are getting your 'fname' variable from... It LOOKS like you should be setting the sourcedoc to iss, rather than fname (unless, that is, you are declaring fname elsewhere in the module and simply passing the value here.)

Regards,
Scott
Works like a charm...Thanks
Aug 9 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.