I have one macro in word, that needs to run in one of my workflow, can anyone help me to run Word macro.
Or My original issue is , I need to set default printer in windows to Microsoft Print to PDF using ui path, I am able to do this using Word Macro.
Your suggestion is needed in both.
Note : Please don’t suggest Bala Reva activities for this.
You can try this in invoke code
Dim defaultPrinter As String = "Microsoft Print to PDF"
Dim printerQuery As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_Printer")
For Each printer As System.Management.ManagementObject In printerQuery.Get()
If printer("Name").ToString().Equals(defaultPrinter) Then
Getting error like, system.management.management.objectsearcher not defined
Did you copy paste the code?
I see a dot after second management
I have also installed system,management.automation pakage
Can you show how you are using it…because I just ran and it threw no errors
Are you using vb.net? or c#
Can you try upgrading system package and check…and also is system present in imports?
I am using vb.net and using Invoke code activity, let me know if I need to install any specific package
Can you search like this and let me know if you are able to see like this…this has to be done in imports at the bottom of your studio beside arguments
If not can you try upgrading the system packages and check again
Yes I am able to search, which one need to select from list
System management only you need to select and also system alone
Try removing invoke code and add again
Okay, twist is, It is working in my local machine, but not in virtual machine
Are printer drivers configured there?
any if its cloud VM then may be the way might be little different…
If you have the mord macro…you can actually convert it into a vb code by including full name spaces…and then use invoke code itself to run the macro on word
Yes printers configured there, But we are getting error on on below class, I have imported necessary namespaces, still it is not working, I have macro on word which is working fine on my VDI, but again, how we can call it using Ui path is the issue
If you can share the macro I can you you an equivalent vb code which can be used in invoke code…
Or other option is call word macro from excel vba
In word, I am using below macro code
Application.ActivePrinter = “Microsoft Print to PDF”
If I am trying to run same code in excel macro then it is showing error over there
Please use excel macro method as shown above