We help IT Professionals succeed at work.

VBS not opening file and copying range

davidam asked
Last Modified: 2012-05-11
Hello Experts,
I have some vbs which is supposed to open a password protected file, copy a range from another file and then close and save the target file.  I cannot see why it is not working.  Can anyone spot it?  The code works up until the point where it is supposed to open and modify the file.  Thank you in advance.
strProtectedFile = "C:\srvr\rie-bin\CLIPr\Nav.xls"
strProtectedFilePassword = "1234"

		Set oProtectedFile = xlApp.Workbooks.Open(strProtectedFile,  strProtectedFilePassword, False)
		oProtectedFile.Worksheets("Sheet1").Visible = True
		oBookToProcess.WorkSheets(1).Range("A2:A11").Copy oProtectedFile.WorkSheets("Sheet1").Range("N8:N17")
		oProtectedFile.Worksheets("Sheet1").Visible = False
		xlApp.DisplayAlerts = False
		oProtectedFile.Close True
		xlApp.DisplayAlerts = True

Open in new window

Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)


No success yet.  I have looked around as much as I can and I have not seen this syntax...it is always just the three items.  Can you tell me what ,0,false,(read only, right),5, and "" are indidcating? Thanks.


Sorry...it did work.  Thank you!!
I would still like to know what the syntax is about if you have a moment.
Sure :)

The syntax is

expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMru, Local, CorruptLoad)

If you open Excel and see it's help file you will get the explanation for each parameter in it :)

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.