Solved

VBA ByRef error

Posted on 2014-10-18
5
156 Views
Last Modified: 2014-10-20
Anyone know why the code below doesn't work?
I have an Excel workbook with a form and a module.
The form contains a button that contains:
Application.Run "startExport"

In the module I have:
Private Sub startExport()
    Dim thePath, theFile As String
   
    thePath = Application.ThisWorkbook.Path
    theFile = Application.ThisWorkbook.Path & "\" & frmProject.txtProject & "Import.csv"
   
    writeProjectLine thePath, theFile
End Sub

The code gives a "ByRef argument type mismatch" error and highlights the variable "thePath" that is shown in bold above.
0
Comment
Question by:classnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:Haris Djulic
ID: 40389253
What is  frmProject.txtProject? If it is folder than the "\" is needed to get to csv file?

Can you post the  code of the writeProjectLine  sub? Or excel?
0
 

Author Comment

by:classnet
ID: 40391685
I've requested that this question be deleted for the following reason:

Found a workaround
0
 
LVL 48

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40391043
You may have found a workaround but note that when you do

Dim thePath, theFile As String

that only theFile is a string. thePath remains as a Variant and that may be your problem.
0
 

Author Closing Comment

by:classnet
ID: 40391686
Not sure if this "Award" will take given the pending delete status.
Not only did your post help with this situation, but it helped me avoid potential issues as well!
I have changed my "slimy hack" workaround.

Thank you!
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40392051
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question