Hi, first off, I'm a bonafide idiot that has no place making any kind of database from the ground up, but here I am. My apologies in advance.
I've been stuck on this problem for a couple of days now and hope you guys can help.
I'm trying to do the following:
1) export data from the results of an Access query to an Excel workbook (princfull-pl.xls)
2) open that workbook.
3) Open a second excel workbook (principles-pl) using the linked info from the former workbook. This workbook calculates some stuff based on princfull-pl's data
4) Close principles-pl and import stuff from it back into Access.
It's a totally backwards way of doing what I need, but it's the only solution I could find. Anyway, if I go into the directory where both of these workbooks are found and I manually open princfull-pl then principles-pl, then the following code placed into principles-pl works just fine:
Private Sub Workbook_Open()
Workbooks("PrincFULL-PL.xls").Close
Application.Visible=False
ActiveWorkbook.Updatelinks=1
ActiveWorkbook.Save
ActiveWorkbook.Close
Excel.Application.Quit
Basically it immediately closes the source workbook, then makes itself invisible and closes. It's just a backhanded way to force (principles-pl) to update before I reimport it to access.
Like I said, it works perfectly when I do it manually. But if I use an Access macro with two RunApp lines:
excel.exe "\\pathtofile\princfull-pl.xls"
excel.exe "\\pathtofile\principles-pl.xls"
The first file opens, but then I get an "Unable to read file" error as soon as the second file executes (indicating the linked data can't be found), and then it follows up with a Run-time error '9', "Subscript out of range" error.
I've tried changing the code in both the excel VB editor and in the access macro to contain the full path of the file, to only use the filename, to use the .xls extension or not use it, and nothing seems to affect the result. I also tried sticking a pause in my Access macro, thinking maybe the second workbook was opening too soon/simultaneously, but even a 30 second delay gets me the same error.
I've done a bunch of googling and am completely at a loss. Can anyone help before I delete the universe in a fit of rage?
Thanks!
I've been stuck on this problem for a couple of days now and hope you guys can help.
I'm trying to do the following:
1) export data from the results of an Access query to an Excel workbook (princfull-pl.xls)
2) open that workbook.
3) Open a second excel workbook (principles-pl) using the linked info from the former workbook. This workbook calculates some stuff based on princfull-pl's data
4) Close principles-pl and import stuff from it back into Access.
It's a totally backwards way of doing what I need, but it's the only solution I could find. Anyway, if I go into the directory where both of these workbooks are found and I manually open princfull-pl then principles-pl, then the following code placed into principles-pl works just fine:
Private Sub Workbook_Open()
Workbooks("PrincFULL-PL.xls").Close
Application.Visible=False
ActiveWorkbook.Updatelinks=1
ActiveWorkbook.Save
ActiveWorkbook.Close
Excel.Application.Quit
Basically it immediately closes the source workbook, then makes itself invisible and closes. It's just a backhanded way to force (principles-pl) to update before I reimport it to access.
Like I said, it works perfectly when I do it manually. But if I use an Access macro with two RunApp lines:
excel.exe "\\pathtofile\princfull-pl.xls"
excel.exe "\\pathtofile\principles-pl.xls"
The first file opens, but then I get an "Unable to read file" error as soon as the second file executes (indicating the linked data can't be found), and then it follows up with a Run-time error '9', "Subscript out of range" error.
I've tried changing the code in both the excel VB editor and in the access macro to contain the full path of the file, to only use the filename, to use the .xls extension or not use it, and nothing seems to affect the result. I also tried sticking a pause in my Access macro, thinking maybe the second workbook was opening too soon/simultaneously, but even a 30 second delay gets me the same error.
I've done a bunch of googling and am completely at a loss. Can anyone help before I delete the universe in a fit of rage?
Thanks!