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
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi ,

In the code line Workbooks.Open ThisWorkbook.Path & "S:\Customer Data\Drawings\PDD\" & "My Dashboard.xlsm" please provide the folder name in your code rather than entire path in your string like Workbooks.Open ThisWorkbook.Path & "\PDD\" & "My Dashboard.xlsm"
 
Upvote 0
Workbooks.Open Filename:="C:\Users\luke\Desktop\FOLDERLOCATE\workbookname.xlsm"

This will work better for you.

Just fill in the path over my C:\ will work fine.
 
Upvote 0
So the folder location is under here: S:\Customer Data\Drawings\PDD meaning S Drive, then the folder called customer data, then sub folder Drawings, then PDD. with your code below do i need to put &"..." for every subfolder?

Hi ,

In the code line Workbooks.Open ThisWorkbook.Path & "S:\Customer Data\Drawings\PDD\" & "My Dashboard.xlsm" please provide the folder name in your code rather than entire path in your string like Workbooks.Open ThisWorkbook.Path & "\PDD\" & "My Dashboard.xlsm"
 
Upvote 0
Matey,

Your complicating it, all you're doing is opening the workbook.

Right click the file copy the entire path and past it in here... between the " "

Workbooks.Open Filename:=""
 
Upvote 0
Thanks but that still produces an error Run time 1004, Method 'Open' of 'Workbooks' failed, any ideas?

Workbooks.Open Filename:="C:\Users\luke\Desktop\FOLDERLOCATE\workbookname.xlsm"

This will work better for you.

Just fill in the path over my C:\ will work fine.
 
Upvote 0
Oh right.

Sub Copytodashboard()
Workbooks.Open Filename:="C:\Users\USER\Desktop\FOLDERLOCATE\workbookname.xlsm"
ActiveWindow.WindowState = xlMinimized - REMOVE
ThisWorkbook.Activate - TYPEICALLY as soon as you open the workbook by doing this you're enesentially activing it so no need to do this either.
End Sub
 
Upvote 0
Still not working. Could there be something wrong with the server I am working on?

Oh right.

Sub Copytodashboard()
Workbooks.Open Filename:="C:\Users\USER\Desktop\FOLDERLOCATE\workbookname.xlsm"
ActiveWindow.WindowState = xlMinimized - REMOVE
ThisWorkbook.Activate - TYPEICALLY as soon as you open the workbook by doing this you're enesentially activing it so no need to do this either.
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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