Solved

VB Excel Macro SetCurrentDirectory issue

Posted on 2014-04-10
3
515 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
[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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
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.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

756 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