macro help

This is a macro that I found in the news group, but I get an error
when I try and run it "type mismatch" any ideas why and what can be
changed to solve it?
it happens at "sMsg = "Enter the Path to the Drawings." & vbCrLf *
"Make sure to end it with a \""
Thanks for any help
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swPart As ModelDoc2
Dim swDwg As DrawingDoc
Const swDocDrawing = 3
Sub main()
Dim sPath As String
Dim sFileSW As String
Dim sFileDWG As String
Dim sFileTitle As String

Dim sMsg As String
sMsg = "Enter the Path to the Drawings." & vbCrLf *
"Make sure to
end it with a \"
sPath = InputBox(sMsg, "Enter Drawing Path", "C:\Temp\")
If sPath = "" Then Exit Sub

Set swApp = CreateObject("SldWorks.Application")

sFileSW = Dir(sPath & "*.slddrw")
Do While sFileSW ""
'Open Drawing - Define Titles
Set swPart = swApp.OpenDoc(sPath & sFileSW, swDocDrawing)
Set swDwg = swPart
'Save As DWG
sFileDWG = Left(sFileSW, Len(sFileSW) - 6) & "DWG"
swPart.SaveAs2 sPath & sFileDWG, 0, True, False
'Close File
sFileTitle = swPart.GetTitle
swApp.CloseDoc sFileTitle
'Next File
sFileSW = Dir
Loop
swApp.SendMsgToUser "Done!"
End Sub
Reply to
Fred
Loading thread data ...
Replace the * with & (spaces on either side of it)
--Brenda
Reply to
Brenda D. Bosley
i needed to slow down the computer for mouse clicking. i checked the time to do this. that way you can have it run 30 frames a second
Reply to
Sean Phillips
Well, there are a few things to consider here.
First off, you want to use a timer-based delay in your code; just running a do-loop somewhere with code will vary widely between machines.
The first obvious choice is to use the VB "Timer" control. But if you are using VBA, or using VB with no forms, this would not be available.
If you *are* using VB, it might be easist to load an invisible form, but there is also another API event-driven timer available; check out the "SetTimer" and "KillTimer" API functions. This requires the "AddressOf" operator, which is not available in VBA, but is event-driven and can be run asychronously.
If you are using VBA, you could always use the API "GetTickCount&" call. This basically returns the number of milliseconds since windows was booted. Since this is not event driven, you'll have to poll the timer yourself until the number of milliseconds has passed. The good thing is you dont have to deal with "Midnight rollover", which you'd have to do with a "real" timer.
It has a Max resolution of 10ms, and seems to round 'up', so if you ask it to wait for 1ms, it returns after 10ms. If you ask it to wait 30ms, it returns after 40ms.
' ---- snip ------------ snip -------------- snip ------------
Private Declare Function GetTickCount Lib "kernel32" () As Long
Sub main() API_Delay 1 End Sub
Public Sub API_Delay(milliseconds As Long)
' pauses code until the number of milliseconds, ' passed as a parameter, has expired. It has a max res of 10 ms. Dim StartTicks As Long, EndTicks As Long Dim tickcount As Long '
StartTicks = GetTickCount EndTicks = StartTicks + milliseconds
' Delay a minimum of milliseconds passed Do tickcount = GetTickCount If tickcount > EndTicks Then Exit Do Loop End Sub
' ---- snip ------------ snip -------------- snip ------------
Reply to
rocheey

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.