
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