Results 1 to 11 of 11
  1. #1
    TriFith is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Czech republic, Prague
    Posts
    37

    VBA script to open link in new tab of currently opened IE

    Hello everyone,
    I would need to open a link from form by a button, but I was able to successfully open only new IE window.
    I would need to open new tab in currently opened IE window (that is because there is already logged in a user in ERP system - if new window is opened user has to log in again -> time consuming and not comfortable to do often)



    currently used code:
    Code:
    Private Sub OpenJde_Click()
    Dim Link As String
    Dim LResponse As Integer
    
    
    If (IsNull(JdeWo) Or JdeWo = "") Then
    LRresponse = MsgBox("JDE WO není není vyplneno!", vbOKOnly, "Info")
    Else
    Link = "http://jde.fanuc.local/jde/ShortcutLauncher?OID=P90CD002_W90CD002B_M852T001&FormDSTmpl=|2|3|4|5|&FormDSData=|" & JdeWo & "|||&FormDSData=|6037701|||"
    
    
    Set browser = CreateObject("InternetExplorer.Application")
       browser.Navigate (Link)
       browser.StatusBar = True
       browser.Toolbar = True
       browser.Visible = True
       browser.Resizable = True
       browser.AddressBar = False
       
    End If
    
    
    End Sub
    any ideas to reach my goal?

    Thanks for all advices!

  2. #2
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

  3. #3
    TriFith is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2013
    Location
    Czech republic, Prague
    Posts
    37
    Hi, thank you for reply.
    I have tried enumeration method and I have failed - I have to admit I am really beginner in VBA so maybe somewhere I am doing mistake...
    My code is:

    Code:
    Enum BrowserNavConstants    navOpenInNewWindow = 0
    End Enum
    
    
    
    
    Public Sub OpenJde_Click()
    Dim Link As String
    Dim LResponse As Integer
    
    
    If (IsNull(JdeWo) Or JdeWo = "") Then
    LRresponse = MsgBox("JDE WO není není vyplneno!", vbOKOnly, "Info")
    Else
    Link = "http://jde.fanuc.local/jde/ShortcutLauncher?OID=P90CD002_W90CD002B_M852T001&FormDSTmpl=|2|3|4|5|&FormDSData=|" & JdeWo & "|||&FormDSData=|6037701|||"
    testtext.Value = Link
    
    
    Set browser = CreateObject("InternetExplorer.Application")
    browser.Navigate (Link), BrowserNavConstants.navOpenInNewTab
    browser.StatusBar = True
    browser.Toolbar = True
    browser.Visible = True
    browser.Resizable = True
    browser.AddressBar = False
       
    End If
    
    
    End Sub
    Tihs code results in error call: Method or data member not found...


    Also I have tried to use second hint with sub method used for opening IE...
    Unfortunatelly once I have added OPTION EXPLICIT statement onto start of code, I am getting errors "Variable not defined".

    May I ask you to try it and send me code as a hint?

    Thank you a lot

  4. #4
    TriFith is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2013
    Location
    Czech republic, Prague
    Posts
    37
    Hello guys,
    closing threat however it was not solved completely...
    I have created new feature in web based ERP interface that can handle login session for new windows of IE...

  5. #5
    TriFith is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2013
    Location
    Czech republic, Prague
    Posts
    37
    Quote Originally Posted by TriFith View Post
    Hello guys,
    closing threat however it was not solved completely...
    I have created new feature in web based ERP interface that can handle login session for new windows of IE...
    I had to reopen this threat a ask you for help once more. My modifications made problems on other side, so I had to remove them.
    So I have to get back to find solution in access database...

    Can someone advice please? Basicly I need only open link in currently opened instance of IE, to keep login session.

    Thank you.

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,411
    Dim browser as object

    Also, I never, NEVER code without Option Explicit.
    It will point out syntax errors in your code and even highlight them! All syntax errors MUST be fixed in order to have cogent reliable code.
    Last edited by davegri; 05-30-2017 at 08:55 PM.

  7. #7
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,411
    Please don't PM me or anyone else in response to posts about solutions. The purpose of this forum is to publicly make solutions available to all.
    In response to your PM, this is what I was suggesting:

    Code:
    Public Sub OpenJde_Click()
    Dim Link As String
    Dim LResponse As Integer
    Dim Browser as Object
    
    If (IsNull(JdeWo) Or JdeWo = "") Then
    LRresponse = MsgBox("JDE WO není není vyplneno!", vbOKOnly, "Info")
    Else
    Link = "http://jde.fanuc.local/jde/ShortcutLauncher?OID=P90CD002_W90CD002B_M852T001&FormDSTmpl=|2|3|4|5|&FormDSData=|" & JdeWo & "|||&FormDSData=|6037701|||"
    testtext.Value = Link
    As for Option Explicit, it should be the second line at the top of each module:
    Code:
    Option Compare Database
    Option Explicit

  8. #8
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    If you use application.followhyperlink("http://domain.com") it will open a new tab within the current browser window. Have you tried that?

    Edit: Oops, didn't see first you are using VBScript?

  9. #9
    TriFith is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2013
    Location
    Czech republic, Prague
    Posts
    37
    Quote Originally Posted by davegri View Post
    Please don't PM me or anyone else in response to posts about solutions. The purpose of this forum is to publicly make solutions available to all.
    In response to your PM, this is what I was suggesting:

    Code:
    Public Sub OpenJde_Click()
    Dim Link As String
    Dim LResponse As Integer
    Dim Browser as Object
    
    If (IsNull(JdeWo) Or JdeWo = "") Then
    LRresponse = MsgBox("JDE WO není není vyplneno!", vbOKOnly, "Info")
    Else
    Link = "http://jde.fanuc.local/jde/ShortcutLauncher?OID=P90CD002_W90CD002B_M852T001&FormDSTmpl=|2|3|4|5|&FormDSData=|" & JdeWo & "|||&FormDSData=|6037701|||"
    testtext.Value = Link


    As for Option Explicit, it should be the second line at the top of each module:
    Code:
    Option Compare Database
    Option Explicit

    Thanks for reply,
    but your suggestion is still opening new window of IE with no active login session...
    Any other ideas?

  10. #10
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,411
    Code:
    Link = "http://jde.fanuc.local/jde/ShortcutLauncher?OID=P90CD002_W90CD002B_M852T001&FormDSTmpl=|2|3|4|5|&FormDSData=|" & JdeWo & "|||&FormDSData=|6037701|||"
    Any other ideas?
    Sorry, No. There's no way for me to verify a local hyperlink.

  11. #11
    TriFith is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2013
    Location
    Czech republic, Prague
    Posts
    37
    Quote Originally Posted by davegri View Post
    Code:
    Link = "http://jde.fanuc.local/jde/ShortcutLauncher?OID=P90CD002_W90CD002B_M852T001&FormDSTmpl=|2|3|4|5|&FormDSData=|" & JdeWo & "|||&FormDSData=|6037701|||"
    Sorry, No. There's no way for me to verify a local hyperlink.
    Understood,
    but you can change the adress for whatever you want.
    google, if you want, or any other. Functionality will be same -> I´ve already tested with other target...

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 07-29-2015, 01:17 PM
  2. Replies: 4
    Last Post: 04-01-2014, 03:56 PM
  3. Replies: 13
    Last Post: 10-12-2011, 12:48 PM
  4. Replies: 10
    Last Post: 09-21-2011, 02:51 PM
  5. Open Accesss DB by batch script
    By micada in forum Access
    Replies: 0
    Last Post: 06-10-2008, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums