Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB Excel Macro SetCurrentDirectory issue

Posted on 2014-04-10
3
Medium Priority
?
519 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 2000 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

Technology Partners: 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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

783 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