Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recognize A Destination

Status
Not open for further replies.

John26

Technical User
May 8, 2006
4
DE
Hi,
This is a little part of my programm's code.When opening this workbook, excel openes another workbook and copies the data out of columns B and C into the first workbook.
This works without any problems on my pc. As soon as I let this thing run on another pc in the network which has also access to the data source, the programm gives me an error message. The debugger shows that the error can be found in the following part:

Sheet1.Range("B1").Select (4. from the bottom)

Code:
Sub Auto_open()

Cells.Select
Selection.ClearContents

Sheet1.Cells(1, 1).Value = "Ticker"
Worksheets("Sheet1").Range("A1").Font.Bold = True
Sheet1.Cells(2, 1).Value = "ISIN"

folderspec = "H:\save\papers\uni\Andreas\EN00\"


[COLOR=green]' Define files [/color]

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files

[COLOR=green] ' select all defined files [/color]

For Each f1 In fc
   Name = f1.Name

 [COLOR=green]  ' condition that CSV-file[/color]

   If Right(Name, 3) = "csv" Then
      Name = folderspec + Name

      [COLOR=green]' open workbook[/color]

      Workbooks.Open (Name)
      Range("B5:C530").Select
      Selection.Copy
      Workbooks(1).Activate
      [b]Sheet1.Range("B1").Select[/b]
      ActiveSheet.Paste
   End If
Next

The proramm opens the source file correctly on my pc, selects the source, copies it, but then it seems that it cannot find the destination where i want to paste it. Has anyone an idea why this works on one pc, but not on the other?

I highly appreciate any hints ;)
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top