In the event below, is it possible to open the Activate the Google Sheet 'Premises…
- User
In the event below, is it possible to open the Activate the Google Sheet 'Premises Assistant Tasks' when this action in the code has been run; chromeOptions.Run chromePath & " -url """ & url & """". Also when the Excel Workbook opens is it possible to activate the Excel Sheet 'PrmPaste'
Sub PremisesRequests() Dim url As String Dim chromePath As String Dim chromeOptions As Object Dim chromeWindow As Object url = "https://docs.google.com/spreadsheets/d/1bV6q14TKrtcK_q_k-WRImsD2AjQr_zEsb7oIJUUcJVc/edit#gid=487024092" ' new premises requests chromePath = """C:\Program Files\Google\Chrome\Application\chrome.exe""" Set chromeOptions = CreateObject("WScript.Shell") chromeOptions.Run chromePath & " -url """ & url & """" Application.Wait (Now + TimeValue("0:00:05")) Dim wpgpr As Workbook Set wpgpr = Workbooks.Open("G:\Shared drives\Swan School Site Premises\PREMISES MANAGEMENT\SERVICE PROVIDERS\zzzz ServProvDocs\Premises Requests.xlsm") wpgpr.Activate MsgBox ("Google Sheet 'Current Jobs' and The Premises Request Sheet have been opened") End Sub
- Assistant
No, it is not possible to open a specific sheet in Google Sheets or Excel using VBA code. The code you provided only opens the Google Sheet and Excel Workbook, but it does not activate a specific sheet within them.
To activate the Google Sheet 'Premises Assistant Tasks', you can modify the code to use the Google Sheets API or other methods to programmatically navigate and activate the specific sheet.
To activate the Excel Sheet 'PrmPaste', you can modify the code to use the Worksheet object's Activate method after opening the workbook:
Dim wpgpr As Workbook Dim prmPasteSheet As Worksheet Set wpgpr = Workbooks.Open("G:\Shared drives\Swan School Site Premises\PREMISES MANAGEMENT\SERVICE PROVIDERS\zzzz ServProvDocs\Premises Requests.xlsm") Set prmPasteSheet = wpgpr.Sheets("PrmPaste") prmPasteSheet.ActivateThis code opens the workbook and then activates the "PrmPaste" sheet within the workbook.