melodramatic
Board Regular
- Joined
- Apr 28, 2003
- Messages
- 170
- Office Version
-
- 365
- Platform
-
- Windows
I have a macro which will pull up a workbook (log file) based on your input (project number, etc.) into the macro file face.
I've figured out building the file open variable, and going back to the macro workbook (which, thankfully, is always a constant named file).
However, once you okay the entry (all built in the macro file), the macro needs to go back to the log file to enter the data. That's where my problem comes, in sending the macro back to the open file with a variable name.
Here's what I've tried:
OBVIOUSLY, I'm doing something wrong, but for the life of me, I can't figure out what (and Microsoft's new help features don't help at all to novices like me).
Help?
I've figured out building the file open variable, and going back to the macro workbook (which, thankfully, is always a constant named file).
However, once you okay the entry (all built in the macro file), the macro needs to go back to the log file to enter the data. That's where my problem comes, in sending the macro back to the open file with a variable name.
Here's what I've tried:
Code:
'TRIAL #A
'Note that Macro is started from the Macro file (Document Control Assignments.xlsm)
Dim MDRProject As String 'this will contain the entire path & file of the log file
MDRProject = Range("C12")
Dim ProjFile As String
ProjFile = Range("H12")
Workbooks.Open Filename:=MDRProject
Windows("Document Control Assignments.xlsm").Activate 'this takes me back to the macro file
Call SetLogEntry
'Up to this point, everything worked fine. Now for the problem... each error takes me to the specific line I've tried
'Trial #1 was...
Windows(ProjFile).Activate 'Doesn't work; Run-time error '9': Subscript out of range
'Trial #2 was...
Workbooks(ProjFile).Activate 'Doesn't work; Run-time error '9': Subscript out of range
Code:
'Trial B was a whole new way, after reading thru posts here...
Dim MDRProject As String
MDRProject = Range("C12")
Workbooks.Open Filename:=MDRProject
Dim ProjFile As String
ProjFile = ActiveWorkbook.Name
Windows("Document Control Assignments.xlsm").Activate
Call SetLogEntry
'Trial #1 was...
Windows(ProjFile).Activate 'Doesn't work; Run-time error '9': Subscript out of range
'Trial #2 was...
Workbooks(ProjFile).Activate 'Doesn't work; Run-time error '9': Subscript out of range
OBVIOUSLY, I'm doing something wrong, but for the life of me, I can't figure out what (and Microsoft's new help features don't help at all to novices like me).
Help?
Last edited: