Join Function in VB Excel2k

G

Guest

I need to create a string literal in Excel 2k VB language. Example below:
Part 1 in a procedure called Worksheet_Change
Dim BkNme As String
BkNme = "Book2.xls"
Part 2 in a procedure called Wrkbk_Open(BkNme)
Dim WrkBk As Workbook
Dim BKPath As String
BKPath = "C:\Documents and Settings\My Documents\Excel\"

WrkBk = Join(BKPath, BkNme, """)
WrkBk should end up with:
"C:\Documents and Settings\My Documents\Excel\Book2.xls"
so that the following function can use
Workbooks.Open Filename:= _ WrkBk, UpdateLinks:=3




WrkBk should endup containing the following:
"C:\Documents and Settings\My Documents\Excel\Book2.xls"
 
N

NickHK

Rick,
Whilst you could use Join:
BkNme = "Book2.xls"
BKPath = "C:\Documents and Settings\My Documents\Excel"
WrkBk = Join(BKPath, BkNme, "\")

it would be more normal to concatenate:
BkNme = "Book2.xls"
BKPath = "C:\Documents and Settings\My Documents\Excel\"
WrkBk = BKPath & BkNme

Also, I'm somewhat doubt about the procedures you have <created>.
If these are supposed to be Excel event routines, it is better to get VBA to
generate the signatures for you, to ensure they are correct.
- Open the required module; e.g. double click Sheet1 in the VBE.
- Select Worksheet from the top left combo in the code pane.
- Select the required event (e.g. Change) from the top right combo in the
code pane.

NickHK
 

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