[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

04/24/2009 at 06:56PM PDT, ID: 24354333
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

excel vba - export import bas module as bas file - Run-Time error 91 - Subscript out of range - trying to set Workbook as filename and path

Asked by natdacruz in Visual Basic Programming, Microsoft Excel Spreadsheet Software, VB Script

Tags: excel vba, - export import bas module, bas file, - Run-Time error 91 - Subscript out of range, - set Workbook filename and path

Im stuck,

Apart from locking a file I've spent a good few nights working on (by duplicating a Sub name in a module - sleep deprivation is never a good thing) I find my self stuck setting an application.workbooks(filename&path)

I have tried a number of combinations of the folder/filepath etc but no joy

I have added the code if anyone can spot the error Ive points a plenty - Im sure its something vsimple... as usual

also if anyone knows how to uncrash an excel file that is well and truly skuppered - ie it wont open at all (when you open it in Visual Basic Editor - it freezes as soon as th code window with the duplicated sub name pops up - so no guesses where the problem is there)
Points galore for that one too :)

Dealines are looming and sleep still evades ... all help gratefully accepted...

code is:

Option Explicit

Sub CopyModule()
       
' copies a module from one workbook to another
' example:
   
Dim strFolder As String
Dim strTempFile As String
Dim wb1 As Excel.Application
Dim wb2 As Excel.Application
Dim TargetFile As String
Dim SourceFile As String
Dim TargetWB As Workbook
Dim SourceWB As Workbook
Dim strModuleName As String
Dim strModuleName1 As String
Dim strModuleName2 As String
Dim strModuleName3 As String
Dim strModuleName4 As String
Dim strModuleName5 As String
Dim strModuleName6 As String
Dim module As Integer

SourceFile = "TS4.0 Control Panel - Backup.xls"
TargetFile = "Code Dump.xls"

Set wb1 = CreateObject("Excel.Application")
Set wb2 = CreateObject("Excel.Application")


    strFolder = "C:\Users\lrc\Desktop\TS4.0 Stable"
    Set TargetWB = wb1.Workbooks(strFolder & "\" & TargetFile)
    Set SourceWB = wb2.Workbooks(strFolder & "\" & SourceFile)

   
    strModuleName1 = "format_Control"
    strModuleName2 = "format_Extracts"
    strModuleName3 = "reportControl"
    strModuleName4 = "format_Control"
    strModuleName5 = "setParameters"
    strModuleName6 = "Module1"
'    If Len(strFolder) = 0 Then strFolder = CurDir

For module = 1 To 6

strModuleName = "strModuleName" & module

    strFolder = strFolder & "\"
    strTempFile = strFolder & strModuleName & ".bas"
    On Error Resume Next
    SourceWB.VBProject.VBComponents(strModuleName).Export strTempFile
    TargetWB.VBProject.VBComponents.Import strTempFile
    Kill strTempFile
    On Error GoTo 0

Next module

MsgBox ("All Done")
   
End Sub


 

[+][-]04/24/09 08:14 PM, ID: 24230650

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/25/09 02:42 PM, ID: 24233650

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/25/09 03:42 PM, ID: 24233787

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Basic Programming, Microsoft Excel Spreadsheet Software, VB Script
Tags: excel vba, - export import bas module, bas file, - Run-Time error 91 - Subscript out of range, - set Workbook filename and path
Sign Up Now!
Solution Provided By: rorya
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04/25/09 03:51 PM, ID: 24233815

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/25/09 04:12 PM, ID: 24233851

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/25/09 04:34 PM, ID: 24233891

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091028-EE-VQP-85 - Hierarchy / EE_QW_EXPERT_20070906