Update workbook without opening it?

R

ryguy7272

I am trying to find a way to copy a range to a closed workbook. Right now,
the workbook is opened and the update is subsequently made.

My code to update the workbook is below:
Private Sub CommandButton1_Click()
Cells(12, 9) = TextBox1.Text
Cells(12, 10) = TextBox2.Text
Cells(12, 11) = TextBox3.Text

Cells(13, 9) = TextBox4.Text
Cells(13, 10) = TextBox5.Text
Cells(13, 11) = TextBox6.Text

Cells(14, 9) = TextBox7.Text
Cells(14, 10) = TextBox8.Text
Cells(14, 11) = TextBox9.Text

'Sub SaveValuesToNetworkFile()
Dim p As String
Dim f As String
Dim s As String
Dim r As String
Dim ws As Worksheet

p = "\\fsrv3\luna\public\Sales Operations\Ryan\"
f = "Destination.xls"
s = "Sheet1"
r = "I12:K14"
Set ws = ActiveSheet
Workbooks.Open (p & f)

' copy range values from current worksheet to same range in network file
ws.Range(r).Copy Workbooks(f).Worksheets(s).Range(r)
' close network file, saving changes
Workbooks(f).Close True

UserForm1.Hide

End Sub


Everything works fine, but the file has to be opened from the LAN, and the
file is getting kind of large now, so it takes a while to open, make the
update, and then close. I was hoping to find a way to simply updating the
workbook, without actually opening the workbook. I believe this method will
be extremely quick…if I can just get it working…

I’d appreciate any and all help on this topic.


Regards,
Ryan---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top