Emoncada
04-26-2012, 11:44 AM
I have the following code
Sub cmdbtnFetchFile_Click()
Dim strAddress As String, res As String
Application.CutCopyMode = False
Selection.Copy
ChDir "C:\"
Workbooks.Open Filename:="C:\SN barcodes.xls"
Sheets("Barcodes").Select
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A2:A65536").Select
Selection.ClearContents
Range("B2:B65536").Select
Selection.Cut
Range("A2").Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close
On Error GoTo NoFile
strAddress = "C:\Incoming grabber.lab"
ActiveWorkbook.FollowHyperlink Address:=strAddress
Exit Sub
NoFile:
MsgBox "Sorry. File is not available at this time", vbInformation, "Error!"
End Sub
This works perfectly, but now having issues with it working on a Windows 7 PC.
It appears it's failing because it's not opening the "Incoming grabber.lab" file as an administrator.
Can someone modify this to work for windows 7?
Sub cmdbtnFetchFile_Click()
Dim strAddress As String, res As String
Application.CutCopyMode = False
Selection.Copy
ChDir "C:\"
Workbooks.Open Filename:="C:\SN barcodes.xls"
Sheets("Barcodes").Select
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A2:A65536").Select
Selection.ClearContents
Range("B2:B65536").Select
Selection.Cut
Range("A2").Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close
On Error GoTo NoFile
strAddress = "C:\Incoming grabber.lab"
ActiveWorkbook.FollowHyperlink Address:=strAddress
Exit Sub
NoFile:
MsgBox "Sorry. File is not available at this time", vbInformation, "Error!"
End Sub
This works perfectly, but now having issues with it working on a Windows 7 PC.
It appears it's failing because it's not opening the "Incoming grabber.lab" file as an administrator.
Can someone modify this to work for windows 7?