File Path

M

Mary

Hi

I have created a procedure that, depending on the radio
button selected will open a document.

All the possible documents are stored in the same folder,
i have repeated the full file path for each radio button
selection. If i move the documents i have to change loads
of lines of code can i store the file path in 1 variable
and then just store the filename in the procedure.

I hope this makes sense

Thanks very much

Mary.
 
J

Jonathan West

Hi Mary,

You have made such a full description of the problem and its solution that
I'm not sure there is much to add!

Could you provide the code for one of your radio buttons? Once I have that,
i can break it down to separate the path from the filename, and show you how
you can fix the rest of the buttons with a bit of find & replace
 
J

Jonathan West

Hi Mary

Change it to this

If Startform.BSGGP = True Then
tempname = pathname & "bsg gp"
ElseIf Startform.BSGGL = True Then
tempname = pathname & "bsg gl"
ElseIf Startform.BSGBP = True Then
tempname = pathname & "bsg bp"
ElseIf Startform.BSGBL = True Then
tempname = pathname & "bsg bl"
ElseIf Startform.BSGHS = True Then
'tcpara variable will be filled with 0 and the T&C part of
the code will
'not run as BSGHS does not need T&Cs
tempname = pathname & "bsg hs"
tcpara = 0
GoTo tcparamissing
Else
MsgBox "You didn't choose a Template Type"
GoTo TheEnd
End If

If the pathname is the same for all the buttons, then you put the following
line of code before the first routine in the userform

Private Const pathname = "G:\Training\BSG Infrastructure Project\New
Templates\"

Then you can do a search & replace on the remainder of the code in the form,
searching for the following text

"G:\Training\BSG Infrastructure Project\New Templates\

to replace it with the following

pathname & "

The quotation marks are very specific there, reproduce them exactly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top