Link to home
Start Free TrialLog in
Avatar of CFMI
CFMIFlag for United States of America

asked on

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

Experts.

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”

Thanks,
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

If "FullName" is supposed to store the fullname of the file, then it should be something like this:
d:\SomeFolder\Somefile.xls
(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


JeffCoachman
Avatar of CFMI

ASKER

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
SpreadsheetForm.jpg
Can you attach your workbook?
Avatar of CFMI

ASKER

Please see attached workbook.
SSReportBuilder.xls
Change

FullName = SSReportBuilder.xls.UserForm1.SSFileName

to

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.
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CFMI

ASKER

Excellent, the VBA code worked well.
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013