MS Excel VBA to use a form field selection as a name


I created a drop down screen so users may select a workbook and after selection, the path and the name appear in the box named: SSReportBuilder.xls.UserForm1.SSFileName

While running the code (another button on the form named UserForm1) a message appears stating “Object Required”.  

The code it highlights is: FullName = SSReportBuilder.xls.UserForm1.SSFileName.

Since there is a need for this form to be open, I have not been able to test it inside VBA.

Please advise as to how the test may be performed or suggest an alternate way to assign a name to the selected “Full Path Excel file”

CFMIFinancial Systems AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
If "FullName" is supposed to store the fullname of the file, then it should be something like this:
(The full drive, path, filename, and extension of the file)

I am not sure how : SSReportBuilder.xls.UserForm1.SSFileName.
...can translate into a full file name...

ad a message box after the line:
FullName = SSReportBuilder.xls.UserForm1.SSFileName.
msgbox FullName
...and see what is returned

CFMIFinancial Systems AnalystAuthor Commented:
I added the message box but while running I receive an error message, :Object Required".   below displays the two statements and I attached the spreadsheet form.

FullName = SSReportBuilder.xls.UserForm1.SSFileName
MsgBox FullName
Martin LissOlder than dirtCommented:
Can you attach your workbook?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

CFMIFinancial Systems AnalystAuthor Commented:
Please see attached workbook.
Martin LissOlder than dirtCommented:

FullName = SSReportBuilder.xls.UserForm1.SSFileName


FullName = UserForm1.SSFileName

What was confusing us was that FullName is an Application property (Application.FullName). You should change your variable's name to avoid confusion.
Martin LissOlder than dirtCommented:
You should also change

Set wbTarget = app.Workbooks.Open(SSFileName)


Set wbTarget = app.Workbooks.Open(FullName)


Set wbTarget = app.Workbooks.Open(UserForm1.SSFileName)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CFMIFinancial Systems AnalystAuthor Commented:
Excellent, the VBA code worked well.
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.