Solved

VB Excel Macro SetCurrentDirectory issue

Posted on 2014-04-10
3
505 Views
Last Modified: 2014-04-10
With the following coding below we are trying to have the coding save the CSV save in whatever directory the file is in and not have the path hard coded.

We are also trying to get this to work with 64-bit.  Any assistance offered would be greatly appreciated.

Sub Write_CVS_XLS()
    Application.DisplayAlerts = False

'
' Write_CVS_XLS Macro
' Writes CVS file then saves XLS file
'

'
    ActiveWorkbook.SaveAs Filename:= _
        "F:\Cadd\Blocks\New Titleblock\Title_Frame_Register.csv", FileFormat:=xlCSV, _
        CreateBackup:=False
    ActiveWorkbook.SaveAs Filename:= _
        "F:\Cadd\Blocks\New Titleblock\Title_Frame_Register.xls", FileFormat:= _
        xlExcel8, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
        , CreateBackup:=False
    Application.DisplayAlerts = True
   
End Sub
0
Comment
Question by:regsamp
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 39991415
Just use the Path property of the current workbook;
ActiveWorkbook.SaveAs Filename:= _
        Activeworkbook.path & "\Title_Frame_Register.csv", FileFormat:=xlCSV, _
        CreateBackup:=False

Open in new window

0
 

Author Comment

by:regsamp
ID: 39991420
Okay, let me try that Graham.
0
 

Author Comment

by:regsamp
ID: 39991472
It worked perfectly, thank you.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

757 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

19 Experts available now in Live!

Get 1:1 Help Now