Hi folks
I have a BATCH code which should copy the filename of a file when dropped onto it and paste it into a specific Excel sheet.
The coding is as follows...
BATCH CODE:
@echo off
:nextFile
set filepath=%~dp1
if "%~1" equ "" goto exitLoop
echo "%~nx1"| clip
wscript "X:\desktop\BAT Programs\VBS\CallEnterInfoMacro.vbs"
shift
goto nextFile
:exitLoop
THE VBS SCRIPT:
Option Explicit
On Error Resume Next
ExcelMacroExample
Sub ExcelMacroExample()
Dim xlApp
Dim xlBook
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("Z:\00. Master Documents\Master Document Update List.xlsm", 0, False)
xlApp.Run "EnterInfo"
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
Then Finally the Macro in Excel:
Sub EnterInfo()
Range("A123456").End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues
Range("A123456").End(xlUp).Offset(0, 1).Value = Now
ActiveWorkbook.Save
End Sub
Now, this worked a few weeks ago, and now for some reason I get a PASTESPECIAL METHOD OF RANGE CLASS FAILED error message and i dont know why!!!
The batch code seems to be copying the filename to the clipboard, but i can only assume it then loses it somewhere along the line.
I dont get why its suddenly not working!
Please help with this - or suggest a different way of doing it??
Thanks very much
Bookmarks