Remote Desktop Breaks my Automated Excel Printing Macro

CyberCorenez

New Member
Joined
Aug 25, 2020
Messages
2
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I need to run automatically an excel macro that PDFs a monthly report and then saves and closes the excel file. My proposed solution is that using Windows Task Scheduler it runs a windows batch print file that runs a VBScript which then runs the excel file. The excel file when it is open then runs a macro that PDFs what I need. All of this I have tested many times locally on my PC and all of it works fine. Now this all needs to run on a remote desktop that is a virtual machine. This is where the issue happens. Everything runs fine up until it opens the excel file, the excel file opens in the background and its icon on the task bar flashes orange, because of this nothing else happens. The macro breaks and does not print, it doesn't even start in the first place. Is there any ideas on how to fix this? I think that it is something in the VBScript that causes this to happen since it is here that the process stops. Here is the coding for the VBScript that opens the excel file.

Code:
 Dim args, objExcel, openExcel

Set args = wScript.Arguments
Set objExcel = CreateObject("Excel.Application")

objExcel.Workbooks.Open args(0)
objExcel.Visible = True

objExcel.Run "ReportPrint"
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close(0)
objExcel.Quit
 

Some videos you may like

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
50,919
Office Version
  1. 365
Platform
  1. Windows
@CyberCorenez
While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered elsewhere.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,852
Messages
5,574,667
Members
412,610
Latest member
bluedusty
Top