TheSwamp
Code Red => VB(A) => Topic started by: ELOQUINTET on October 24, 2007, 09:35:04 AM
-
Hey guys,
I got a program that works fine except I just want the initial directory to be Autosave. I know this is probably easy but I can't seem to figure out how to change it to work here. Can somebody help me out?
Public Function GetFileOpen(Title As String, InitFolder As String, Filter As String) As String
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
With OpenFile
.hwndOwner = ThisDrawing.hWnd
.lStructSize = Len(OpenFile)
.lpstrFilter = Filter
.nFilterIndex = 1
.lpstrFile = String(257, 0)
.nMaxFile = Len(OpenFile.lpstrFile) - 1
.lpstrInitialDir = InitFolder
.lpstrFileTitle = OpenFile.lpstrFile
.nMaxFileTitle = OpenFile.nMaxFile
.lpstrTitle = "Select File"
.flags = 4
.lpTemplateName = "Test"
End With
'
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
GetFileOpen = ""
Else
GetFileOpen = Left$(OpenFile.lpstrFile, InStr(OpenFile.lpstrFile, Chr$(0)) - 1)
End If
End Function
-
I just want the initial directory to be Autosave
I don't quite get what you are asking.
The code that you posted, does that give you the name of an open dwg or any dwg?
-
No idea.... but:
.lpstrInitialDir = InitFolder
To:
.lpstrInitialDir = ThisDrawing.GetVariable("SAVEFILEPATH")
and remove the argument 'InitFolder As String from the function
? ? ?
wait for the vb/a masters
-
Luis, that should work ...
-
basically the routine allows you to open bak files then saves them as dwg files and as I would mostly use this to recover autosaves i want it to start there make sense. i'll give it a try and let you know. thanks everybody
-
Hey,
I got the routine working but when I try to Autoload it as I do all of my other vba routines it gives me this error upon loading
error: bad character read (octal): 21
and if i run it it says macro not found
but if i manually load it it runs fine
What does this error mean?
-
A quick search on Google suggests that there might be some goofy characters (maybe a linefeed or return or something like that) gumming up the works in your program.
What happens if you click on DEBUG --> COMPILE? Does it find anything out of the ordinary??
-
What is the method you are using for loading the macro?