Open Workbook from Access Problem

Carly

Active Member
Joined
Aug 21, 2002
Messages
370
I have got an access database which opens an Excel workbook using the following code:
Code:
With CreateObject("Excel.Application")
   .Workbooks.Open "\\stoke\analytic$\Price Increase\MarginRecoveryPlan " & vMonth & "\zPricingExtractManipulation\PricingExtractManipulation-MACRO.xlsm", True
   .Visible = True
End With
DoCmd.Close acForm, "FrontPage", acSaveNo
DoCmd.Quit
The Excel workbook as a form which loads when the workbook is opened as follows:
Code:
Private Sub Workbook_Open()
   frmStages.Show
End Sub
The problem I have got is the Access database just hangs instead of closing until something is done with the form on the excel workbook, which is not what I want to happen...& if I change the form on the Excel spreadsheet to be ShowModal = False, then the excel workbook doesnt seem to open properly.

Is there anything I can do so that it works like, Access Database closes, Excel workbook open as if I was manually doing so?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Is the DoCmd.Quit intended to close Access? I think you need to do Application.Quit.

BICBW...
 
Upvote 0
It is...I will try this just to check if it does something differently, however, this code works normally without the automatic open form bit in excel.

Will let you know how it goes.
 
Upvote 0
What is the Excel userform meant to do?

Do you actually want it to he shown?
 
Upvote 0
Changing it to Application.Quit makes no difference.

The Excel userform just pops up on open which i want it to do, but I would like it to close access before this happens & without the form being there, that is exactly what happens with this code.

In theory, I want to close access, & open excel with the form popping up as it should on open.
 
Upvote 0
I do apologise, however, I was just at lunch and was about to post the answer when I got back, but you obviously beat me to it.

I cross post to capture as many peoples brains as possible on a post that wasn't answered as quickly as usual. To help myself & others.

I didn't realise there were rules about this!
 
Upvote 0
This has now been completely answered on the other forum:

Code:
Call Shell("Excel.EXE ""\\stoke\analytic$\Price Increase\MarginRecoveryPlan " & vMonth & "\zPricingExtractManipulation\PricingExtractManipulation-MACRO.xlsm""", vbNormalFocus)
 
Upvote 0
Carly

Wasn't it suggested you use a hyperlink via FollowHyperlink instead of Shell?
 
Upvote 0
Carly

Wasn't it suggested you use a hyperlink via FollowHyperlink instead of Shell?

I tried the hyperlink way and the result was the same as my original problem...Call Shell works exactly how I want it to work, so I'm very happy with the way this is working.
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top