Update UDF for Win 10

picklefactory

Well-known Member
Joined
Jan 28, 2005
Messages
506
Office Version
  1. 365
Platform
  1. Windows
Hi folks
I have a simple UDF just to compare text files and highlight any lines between the two that do not match, it simply runs the basic DOS file compare function but just simplifies the usage. Just had my work pc upgraded to Win 10 (Yep... just), and now find that this doesn't work any more, and I don't know if it's
a/ Win 10 doesn't support this function anymore or
b/ The code just needs updating to suit.
Would anyone have an inkling at all please?
Thanks

Code:
Sub CompareFiles()
' Sub to run DOS File Compare function without all the typing
   Dim varFile1, varFile2, varFile3 ' Set variable names
   varFile1 = Application.GetOpenFilename("All Files (*.*), *.*", , _
                        "Select first comparison file") ' Open Explorer window to select 1st program to compare
   If TypeName(varFile1) = "Boolean" Then Exit Sub
   varFile2 = Application.GetOpenFilename("All Files (*.*), *.*", , _
                        "Select second comparison file") ' Open Explorer window to select 2nd program to compare
   If TypeName(varFile2) = "Boolean" Then Exit Sub
   varFile3 = Application.GetSaveAsFilename(Title:="Specify output file name") ' Open Explorer window to designate path and file name
   'for resulting comparison file
   If TypeName(varFile3) = "Boolean" Then Exit Sub
   Shell "cmd.exe /c ""fc /n """ & varFile1 & """ """ & varFile2 & """ >""" & varFile3 & """"

End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
A guess is DOS command prompts can't be launched programtically due to Win 10 security? Have you checked with those who installed the upgrade?
 
Upvote 0
Thanks Jack
Never gave that a thought TBH, it's a new pc entirely. I'll fire a question to our IT.
 
Upvote 0
Hallo, if there are security issues, try to write your Shell-command in a *.bat- file. This will not work either, but if you create a shortcut (*.lnk) and address this in the VBA-Shell it shoud work. regards
 
Last edited:
Upvote 0
Thanks Fennek
The batch file is easy, but how do I create/use the *.lnk shortcut? Is that just as easy?
 
Upvote 0
Haha... thanks Jack, that doesn't fill me with confidence. I've been aGoogling, and it doesn't look simple.
:)
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,144
Members
448,552
Latest member
WORKINGWITHNOLEADER

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top