Calling Excel code within Access code? 
Author Message
 Calling Excel code within Access code?

I have the following code in Access 97 attached to a button that will open
an Excel 97 file if the user presses OK on the message box.

Private Sub Cost_Button_Click()
On Error GoTo Err_Cost_Button_Click
    Dim Msg, Style, Title, Response
    Msg = "This button will launch Excel and minimize the database window."
    Style = 4161  'vbOKCancel + vbInformation + vbSystemModal
    Title = "Launching Excel..."
    Response = MsgBox(Msg, Style, Title)
    If Response = vbCancel Then End
    FollowHyperlink "costdata.xls#Welcome!A1"

Exit_Cost_Button_Click:
    Exit Sub

Err_Cost_Button_Click:
    MsgBox Err.Description
    Resume Exit_Cost_Button_Click
End Sub

What I'd like to do is add the following line of code after the
FollowHyperlink line that will run in Excel and not in Access.  There is a
command from Excel
Windows(1).WindowState = xlMaximized
that maximizes the current window in Excel but Access thinks I'm trying to
run that command in Access and thus doesn't understand it.  Is there a
syntax that tells Access "run the following command in X application"

My concern is making sure that when the hyperlink is followed, both the
Excel Application window and the worksheet window are maximized and I would
prefer to do this from Access and not add the code to the Excel file.  Any
other ideas on how to do this would also be appreciated.

Thanks for your help

-Mark



Sun, 10 Feb 2002 03:00:00 GMT  
 Calling Excel code within Access code?
I don't think that would do it... You need to use Automation instead.  Look
at Application.Run method and search www.deja.com and support.microsoft.com
for more Automation samples./

< http://www.mvps.org/access/modules/mdl0006.htm >
< http://www.mvps.org/access/modules/mdl0007.htm >
< http://www.mvps.org/access/modules/mdl0035.htm >

  -- Dev


: I have the following code in Access 97 attached to a button that will open
: an Excel 97 file if the user presses OK on the message box.
:
: Private Sub Cost_Button_Click()
: On Error GoTo Err_Cost_Button_Click
:     Dim Msg, Style, Title, Response
:     Msg = "This button will launch Excel and minimize the database
window."
:     Style = 4161  'vbOKCancel + vbInformation + vbSystemModal
:     Title = "Launching Excel..."
:     Response = MsgBox(Msg, Style, Title)
:     If Response = vbCancel Then End
:     FollowHyperlink "costdata.xls#Welcome!A1"
:
: Exit_Cost_Button_Click:
:     Exit Sub
:
: Err_Cost_Button_Click:
:     MsgBox Err.Description
:     Resume Exit_Cost_Button_Click
: End Sub
:
: What I'd like to do is add the following line of code after the
: FollowHyperlink line that will run in Excel and not in Access.  There is a
: command from Excel
: Windows(1).WindowState = xlMaximized
: that maximizes the current window in Excel but Access thinks I'm trying to
: run that command in Access and thus doesn't understand it.  Is there a
: syntax that tells Access "run the following command in X application"
:
: My concern is making sure that when the hyperlink is followed, both the
: Excel Application window and the worksheet window are maximized and I
would
: prefer to do this from Access and not add the code to the Excel file.  Any
: other ideas on how to do this would also be appreciated.
:
: Thanks for your help
:
: -Mark
:
:
:



Sun, 10 Feb 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Executing Excel-VBA code within a Access-database

2. running code from Access that runs code in an excel spreadsheet

3. Call Stack from within Code

4. html code within vb code

5. Call Excel functions within Access

6. problem with access coding accessing an excel spreadsheet

7. Calling Access from Access stops code in debug mode

8. Vba code which can execute FTP script from within the Access 97 module

9. How to open another database from within Access using code

10. ZIP files from within Access code

11. Controlling Source Code Environment within Access

12. Compressing Access files from within VB code

 

 
Powered by phpBB® Forum Software