Copy Data, Open Another Workbook and paste data

stroffso

Board Regular
Joined
Jul 12, 2016
Messages
160
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am using some code to
1. Copy data from one sheet.
2. Open another file and select a specific tab
3. Pate the file

However it looks like I am making an error around the directory naming convention when i go to open the file i want to copy to. Can someone please tell me where I am going wrong? The File is called my Dashboard and is in my S Drive. i think once i get this part sorted I can do the rest, here is the code I have so far, thanks

Sub Copytodashboard()
Workbooks.Open ThisWorkbook.Path & "S:\Customer Data\Drawings\PDD\" & "My Dashboard.xlsm"
ActiveWindow.WindowState = xlMinimized
ThisWorkbook.Activate
End Sub
 
Workbooks.Open Filename:=" S:\Customer Data\Drawings\PDD\" & "My Dashboard.xlsm"

thanks


So just so I understand after your PDD folder you have another folder and this folder is called &?

Then your excel workbook is called My Dashboard.xlsm?

You also have an issue with using " " where your & is you can't do this

It should look like this -

Workbooks.Open Filename:="S:\Customer Data\Drawings\PDD\&\My Dashboard.xlsm"
 
Last edited:
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
No there is no folder called &, i just thought I had to use this to show that this was the file. However I have tried using this and it still doesnt work
"S:\Customer Data\Drawings\PDD\My Dashboard.xlsm"
I do think its something to do with our server name ie what is behind the S: or would i be wrong?

 
Upvote 0
No there is no folder called &, i just thought I had to use this to show that this was the file. However I have tried using this and it still doesnt work
"S:\Customer Data\Drawings\PDD\My Dashboard.xlsm"
I do think its something to do with our server name ie what is behind the S: or would i be wrong?


Interesting I use this for everything I use personally.

It could be, let me try on my end now for you.

Wont be long.
 
Upvote 0
Interesting I use this for everything I use personally.

It could be, let me try on my end now for you.

Wont be long.

Alright so I tried on my networkdrive from my local machine using what I've mentioned to you.

It works fine.

So what error are you getting exactly?
 
Upvote 0
Well then it must be the wat I am putting the network link before the S.

The error is

Run Time error '1004':
method 'Open' Of object 'workbooks' failed

thanks for your help
Alright so I tried on my networkdrive from my local machine using what I've mentioned to you.

It works fine.

So what error are you getting exactly?
 
Upvote 0
Well then it must be the wat I am putting the network link before the S.

The error is

Run Time error '1004':
method 'Open' Of object 'workbooks' failed

thanks for your help

Alright this is what I'd do, create a folder in your C Drive root directory Customer Data\Drawings\PDD\ with the xlsm file within.

Workbooks.Open Filename:="C:\Customer Data\Drawings\PDD\My Dashboard.xlsm"

Create a new sub
ensure the path is spot on as I noticed when you did a copy earlier you have a " S:\ ( a space between the " and the S
Use a new location for the workbook to open lets say C:\users\desktop etc
What happens when you simply step through the code by pressing F8?

To be honest it's probably something very simple.

sub new()

Workbooks.Open Filename:="C:\Customer Data\Drawings\PDD\My Dashboard.xlsm"

This is to be done in a completely new xls file.
 
Upvote 0
Its definitely something on this end. I tried that and although it didnt work i tried using a file name that didnt exist and it said the file name didnt exist which leads me to believe the function itself is working correctly. I will wait until I am on my own laptop before running again, thanks for your help

Alright this is what I'd do, create a folder in your C Drive root directory Customer Data\Drawings\PDD\ with the xlsm file within.

Workbooks.Open Filename:="C:\Customer Data\Drawings\PDD\My Dashboard.xlsm"

Create a new sub
ensure the path is spot on as I noticed when you did a copy earlier you have a " S:\ ( a space between the " and the S
Use a new location for the workbook to open lets say C:\users\desktop etc
What happens when you simply step through the code by pressing F8?

To be honest it's probably something very simple.

sub new()

Workbooks.Open Filename:="C:\Customer Data\Drawings\PDD\My Dashboard.xlsm"

This is to be done in a completely new xls file.
 
Upvote 0
Its definitely something on this end. I tried that and although it didnt work i tried using a file name that didnt exist and it said the file name didnt exist which leads me to believe the function itself is working correctly. I will wait until I am on my own laptop before running again, thanks for your help


perfect.

That will do it.

It's no trouble at all glad I share some of my knowledge (some) lol...

Good luck mate!
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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