Solved

VBA ByRef error

Posted on 2014-10-18
5
148 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
  • 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 45

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 45

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now