dcsimg
Results 1 to 11 of 11

Thread: MVB syntax error on Attribute VB_name

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2009
    Posts
    3

    MVB syntax error on Attribute VB_name

    Hi
    I get a compile error on first line of the code that is in the text file attachment


    I opened Word 2007
    alt-F11 to bring up MVB
    imported the bas file
    and selected tools->macros, then ran it

    "Compile Error: Syntax error" on the very first line,
    It said this was wrong Attribute VB_Name = "Word2TWiki"



    First few lines of Code is below===>>
    Attribute VB_Name = "Word2TWiki"
    'Attribute VB_Name = "Word2Wiki"
    Dim FileName As String, FolderName As String, doctitle As String
    Dim htmlFile As String

    Sub Word2TWiki()
    'This function can be used to convert a Word doc to the TWiki formatting language
    'For references: http://www.twiki.org/cgi-bin/view/Pl...ToTWikiMLAddOn
    Dim runtime As Single 'new
    Dim tocfind As Boolean
    runtime = Timer
    Application.ScreenUpdating = False

    .
    .
    .

    FULL file is attached


    thanks
    Dennis
    Attached Files Attached Files

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    40,526

    Re: MVB syntax error on Attribute VB_name

    Welcome to VBForums

    The problem is with how you "imported the bas file", as that line should be in the file - but not in the code (it is to tell VB what to use as the name of the file from within code, and in the window title etc).

    It seems that you copied & pasted the contents of the file, whereas what you should do is right-click on the Project window and select "Import file...". When I did that, the red line was not visible, but the part in quotes was used as the name.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2009
    Posts
    3

    Re: MVB syntax error on Attribute VB_name

    Thanks for the help, yes, import got me past the problem on the first line of that bas file.

    However, I now get another syntax error :

    ConvertTables
    ActiveDocument.Save
    ' Copy to clipboard
    ActiveDocument.Content.Copy

    Dim MyDataObj As New DataObject, GetOffClipboard As Variant

    It flags what I highlighted and the pop-up says

    Compile error: User-defined type not defined.

    thanks
    Dennis

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,954

    Re: MVB syntax error on Attribute VB_name

    Dim MyDataObj As New DataObject,
    add a reference to msforms2 controls (object library)
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2009
    Posts
    3

    Re: MVB syntax error on Attribute VB_name

    Hi Pete,
    Were you referring to my post as code snippets? If so, my original post has the complete script/code attached. code snippets posted came from that attached file.

    I dont have msforms2 as being available.

    Im trying to compile a macro for ms word, through alt-F11 in win word, which pops up mvb.

    Thanx
    Dennis

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,954

    Re: MVB syntax error on Attribute VB_name

    if you add a userform it automatically adds a reference to msforms2 object library

    otherwise you can go to menu > tools > references, find in the list and check the box
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,264

    Re: MVB syntax error on Attribute VB_name

    I have an Access 2007 form where when a button's clicked some data is concatenated into a string, of which there's more data in the string than what a MsgBox will show and I would like to have it automatically be copied to the clipboard so I can verify the contents while I'm still building the functionality of the form. I got this code:
    Code:
    Dim MyData As DataObject
    Set MyData = New DataObject
    MyData.SetText MyStringVariableHere
    MyData.PutInClipboard
    And I notice right off the bat that I get an "Object not defined error" and I found on this page http://word.mvps.org/FAQS/MacrosVBA/...eClipboard.htm that I need to add the reference to "Microsoft Forms 2.0 Object Library".

    Here's the problem, when I check the list of reference it's not there, where is it?

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,954

    Re: MVB syntax error on Attribute VB_name

    as i do not have access or 2007, i can not answer this question, access is different to word or excel, but i assume there is some method to use clipboard

    see http://msdn.microsoft.com/en-us/library/bb258151.aspx for 2 methods
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  9. #9
    Super Moderator Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    11,989

    Re: MVB syntax error on Attribute VB_name

    Can I see your dbf file for a faster resolution? Or if it is not for public view then can you mail it to me?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - 2015 IMP Links : Acceptable Use Policy, FAQ
    MyGear:
    ACER R7 (Win 8.1+Office 2013+VS2013) || Sony VPCCB-45FN with a Win10+Office 2010. || Mac Book Pro (10.6.8) with Office 2011

  10. #10
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,264

    Re: MVB syntax error on Attribute VB_name

    Quote Originally Posted by westconn1 View Post
    as i do not have access or 2007, i can not answer this question, access is different to word or excel, but i assume there is some method to use clipboard

    see http://msdn.microsoft.com/en-us/library/bb258151.aspx for 2 methods
    That article looks promising, although I did manage to finish debugging the form without copying the data to the clipboard (it was tedious though) but it's good to see an answer to this.
    Quote Originally Posted by koolsid View Post
    Can I see your dbf file for a faster resolution? Or if it is not for public view then can you mail it to me?
    Unfortunately I can't send anyone the file as it holds personal information that would violate the HIPAA laws if I send it to anyone.

  11. #11
    Super Moderator Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    11,989

    Re: MVB syntax error on Attribute VB_name

    No i mean deleting the info it holds and simply uploading the structure....
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - 2015 IMP Links : Acceptable Use Policy, FAQ
    MyGear:
    ACER R7 (Win 8.1+Office 2013+VS2013) || Sony VPCCB-45FN with a Win10+Office 2010. || Mac Book Pro (10.6.8) with Office 2011

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width