none
VBA Code not workinng under a Citrix Desktop Environment RRS feed

  • Question

  • Hi

    I have a piece of code that is working well under a standard Windows10 environment.  However I am now working under a Citrix Environment running a virtual desktop.  Whilst the4 code opens the MS Project file ok from Excel it fails to run the MS Project Macro stated in the code.  I have annotated in the code the line that is failing to run.

    Any help would be appreciated.

    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
     (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
     ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Sub OpenFileInDefaultApp(FullName As String)
        ShellExecute 0, vbNullString, FullName, 0&, 0&, 1
    End Sub
    
    Sub OpenProject()
    Dim projApp As Object 'MSProject.Application
    Dim xlApp As Excel.Application
    Dim objFSO As Object
    Dim objFolder As Object
    Dim objFile As Object
    Dim fname As String
    
    'Excel Set up to access MS Project
    On Error Resume Next
    Set projApp = GetObject(, "MSProject.Application")
    If projApp Is Nothing Then
        Set projApp = CreateObject("MSProject.Application") 'New MSProject.Application
    End If
    projApp.Visible = True
    
    'Create an instance of the FileSystemObject
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    'Get the folder object
    Set objFolder = objFSO.GetFolder("H:\NFU Plan Reporting\Plans\")
    
    'loops through each file in the directory and prints their names and path
    For Each objFile In objFolder.Files
        Application.DisplayAlerts = False
            fname = objFile.Name
            If fname = "desktop.ini" Then
                GoTo NextOne:
            End If
            OpenFileInDefaultApp "H:\NFU Plan Reporting\Plans\" & fname
            projApp.Application.Run "NFU_CreateSlippageReport" ' THIS LINE OF CODE FAILS TO RUN
            projApp.Application.FileCloseEx projApp.pjSave
        Application.DisplayAlerts = True
    
        'Save each Slippage Report
            fname = projApp.ActiveProject.Name 'Left(fname, Len(fname) - 4)
            Workbooks(fname).Activate
            Workbooks(fname).SaveAs
    NextOne:
    Next objFile
    Set projApp = Nothing
    xlApp.Application.Visible = True
    MsgBox ("Slippage Reports have been created for all plans.......")
    End Sub

    Many thanks

    Tony


    TKHussar


    • Edited by TKHussar Friday, September 29, 2017 11:53 AM
    Friday, September 29, 2017 11:50 AM

Answers

  • If it is working fine outside of Citrix and failing within, then I would Contact Citrix support.  The Citrix  software blocks ports and functions to control environment.   

    Michael Wharton, MVP, MBA, PMP, MCT, MCTS, MCSD, MCSE+I, MCDBA
    Website http://www.WhartonComputer.com
    Blog http://MyProjectExpert.com contains my field notes and SQL queries

    • Marked as answer by TKHussar Friday, September 29, 2017 1:17 PM
    Friday, September 29, 2017 12:57 PM
    Moderator

All replies

  • If it is working fine outside of Citrix and failing within, then I would Contact Citrix support.  The Citrix  software blocks ports and functions to control environment.   

    Michael Wharton, MVP, MBA, PMP, MCT, MCTS, MCSD, MCSE+I, MCDBA
    Website http://www.WhartonComputer.com
    Blog http://MyProjectExpert.com contains my field notes and SQL queries

    • Marked as answer by TKHussar Friday, September 29, 2017 1:17 PM
    Friday, September 29, 2017 12:57 PM
    Moderator
  • Hi Michael

    Many thanks for your response.

    Tony


    TKHussar

    Friday, September 29, 2017 1:17 PM
  • I agree with Michael Wharton.

    Please consult Citrx, and you could find some solution from Citrix support.


    Ashidacchi


    • Edited by Ashidacchi Friday, September 29, 2017 1:19 PM
    Friday, September 29, 2017 1:18 PM